IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Need clarification about UNSTRING logic


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
kumar_jalluri

New User


Joined: 02 Jun 2005
Posts: 24
Location: PUNE

PostPosted: Fri Aug 10, 2007 2:52 pm
Reply with quote

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
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Fri Aug 10, 2007 6:53 pm
Reply with quote

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
View user's profile Send private message
mhf

New User


Joined: 16 May 2006
Posts: 3
Location: Johannesburg

PostPosted: Fri Aug 10, 2007 9:51 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Fri Aug 10, 2007 10:07 pm
Reply with quote

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
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sat Aug 11, 2007 8:00 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Finding faulty logic Subscript out of... COBOL Programming 5
This topic is locked: you cannot edit posts or make replies. Need assistance in job scheduling logic. Mainframe Interview Questions 2
No new posts Rexx Logic error while adding seperat... CLIST & REXX 3
No new posts PL/1 Callback address logic in z/OS C... PL/I & Assembler 1
No new posts Handling the numeric data in unstring... COBOL Programming 18
Search our Forums:

Back to Top