Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Need clarification about UNSTRING logic

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Need clarification about UNSTRING logic
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    Post subject:
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    Post subject: Re: Need clarification about UNSTRING logic
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

Site Director


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

PostPosted: Fri Aug 10, 2007 10:07 pm    Post subject:
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Wildcard logic in COBOL dudenithy COBOL Programming 13 Thu Sep 01, 2016 7:36 pm
No new posts Unstring list of values into an array. Roshnii COBOL Programming 8 Mon Jun 27, 2016 6:25 pm
No new posts Need clarification of VSAM FCT and DF... pkmurali CICS 15 Sun Apr 10, 2016 1:06 am
No new posts Sort Logic to extract data scorp_rahul23 DFSORT/ICETOOL 13 Tue Mar 01, 2016 1:22 am
No new posts Need a logic to validate the data in ... sandeep kumar302 COBOL Programming 17 Mon Feb 01, 2016 3:30 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us