View previous topic :: View next topic
|
Author |
Message |
kumar_jalluri
New User
Joined: 02 Jun 2005 Posts: 24 Location: PUNE
|
|
|
|
Hi
Here is one code
UNSTRING WO_INST_ADDRESS
DELIMITED BY "|"
INTO WS_ADDR_LINE_1
WS_ADDR_LINE_2
WS_ADDR_LINE_3
WS_ADDR_LINE_4
WS_POST_CODE.
After this I have to check
if WS_ADDR_LINE_1 is blank then move WS_ADDR_LINE_2 up
similarly for other address lines also.
Is there any efficient way to do it? |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
You do not want to change your UNSTRING delimiter.
You are stuck with checking each and moving them up.
I would:
Code: |
IF WS-ADDR-LINE-3 = SPACES
THEN
MOVE WS-ADDR-LINE-4 TO WS-ADDR-LINE-3
MOVE SPACES TO WS-ADDR-LINE-4
END-IF
IF WS-ADDR-LINE-2 = SPACES
THEN
MOVE WS-ADDR-LINE-3 TO WS-ADDR-LINE-2
MOVE WS-ADDR-LINE-4 TO WS-ADDR-LINE-3
MOVE SPACES TO WS-ADDR-LINE-4
END-IF
IF WS-ADDR-LINE-1 = SPACES
THEN
MOVE WS-ADDR-LINE-2 TO WS-ADDR-LINE-1
MOVE WS-ADDR-LINE-3 TO WS-ADDR-LINE-2
MOVE WS-ADDR-LINE-4 TO WS-ADDR-LINE-3
MOVE SPACES TO WS-ADDR-LINE-4
END-IF
|
|
|
Back to top |
|
|
mhf
New User
Joined: 16 May 2006 Posts: 3 Location: Johannesburg
|
|
|
|
The UNSTRING verb is a nice way of coding fewer lines. But in terms of efficiency, the compiler is going intepret the UNSTRING verb and generate more code than what you would have coded if you were to code/unstring the field with your own code. The difference in performance is negligible. I would a sacrifice a small increase in performance for readability by using the UNSTRING verb as you have done.
dbz do you agree? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
UNSTRING is fine for breaking up the component fields, but it will not provide the requirement to "shift" the lines up so that the content is filled from the top with the lower entries containing spaces.
One question i had is what should happen if the person who enters the data keys in line2 and line4 and leaves 1 & 3 blank or for whatever reason only enters data in line3? Etc. . . . |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Hi Kumar,
After the UNSTRING you could try to STRING delim by " " (space) into an "WS-ALL-STRINGS field. This will eliminate the "empty" fields.
Spaces embedded in each field can be a problem. I don't remember and haven't checked how UNSTRING places the string into each receiving field, but initing them with X'FF' and STRINGing delimed by X'FF' may solve that problem (8/13 - I tried the X'FF' - it didn't work. I was hoping that UNSTRING did a Ref/Mod MOVE of the string sements to the receiving field, but no such luck.)
But you can delim the STRING w/multiple spaces if you know what the maximum spaces in each string might possibly be. |
|
Back to top |
|
|
|