RPGLE substring and break word with different fields

5 pts.
Tags:
AS/400
RPGLE
Hi, I have encounter issues about sub string with from input and store in destination fields with different field length. I have four 35A input fields condition with if character at position 35A of input line 1 is not a space and first character of input line 2 is not space, then will move last word of input line field 1 to destination field 2.Same rules will applied to destination field with line 2 ,3,4. It also will prompted  error after movement input word if the destination fields length no enough long to store total four input fields. Scenario 1: Input 1 35A: |No. 1241,Old Klang road,  Tom Cater| Input 2 35A: |rried ,58785 Windfall Stand  Johnan| Input 3 35A: | Stress bay   White hall     CHIGNA| Input 4 35A: |LL ST JAMES                        | Expected result store to 4 line destination fields with 40A each of line. Destination Field 1 40A: |No. 1241,Old Klang road, Tom           | Destination Field 2 40A: |Caterrried ,58785 Windfall Stand       | Destination Field 3 40A: |Johnan Stress bay   White hall         |- The 'bay  ' world remain Destination Field 4 40A: |CHIGNALL ST JAMES                      |
Scenario 2: [CODE] Input 1 35A: |No. 1241,Old Klang road,  Tom Cater| Input 2 35A: |rried ,58785 Windfall Stand  Johnan| Input 3 35A: | Stress bay   White hall     CHIGNA| Input 4 35A: |LL ST JAMES TAXES STATES STAND CITY| [/CODE] Expected result store to 4 line destination fields with 40A each of line. [CODE] Destination Field 1 40A: |No. 1241,Old Klang road, Tom           | Destination Field 2 40A: |Caterrried ,58785 Windfall Stand       | Destination Field 3 40A: |Johnan Stress bay   White hall         |- The 'bay  ' world with space remain  Destination Field 4 40A: |CHIGNALL ST JAMES TAXES STATES STAND CI|- Prompt error msg as the 'TY' no enough fit in the 40 length field   [/CODE] Appreciated with any help. Thanks!
1

Answer Wiki

Thanks. We'll let you know when a new response is added.

You would use a combination of functions to concenate and %TRIM the fields.

NewString = %trim(FIELDA) + %trim(FIELDB)
Another option is to use the %SCAN function and scan for the blank in the string.
Check the position it's found in and base your substring on that position. 

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • ToddN2000
    Your best bet may be to put all the input strings into one field. Scan for a blank and get it position. Scan for the next blank. If the two strings will fit in the output string value, scan for the next blank and repeat the the out put string is filled then update it. Repeat the scan process and filling the new output stings with full values if they will fit the max length without splitting a word.
    135,295 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: