Give me some ideas .. how to solve this problem



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

Re: Give me some ideas .. how to solve this problem

Postby ronners » Thu Feb 09, 2012 4:56 pm

You're right, I didn't "bother", I just tried to be helpful.
Obviously that wasn't good enough for you so I won't be doing it again.
goodbye.
ronners
 
Posts: 4
Joined: Tue Dec 20, 2011 7:10 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Re: Give me some ideas .. how to solve this problem

 

Re: Give me some ideas .. how to solve this problem

Postby BillyBoyo » Thu Feb 09, 2012 5:04 pm

Don't take it so hard. Just understand it is not so "helpful", no matter the intent (which I didn't question), to answer the wrong thing.

If I knew you were going to upsticks in a huff I'd not have bothered to help you out at all with the tips. What a waste of both our times.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: Give me some ideas .. how to solve this problem

Postby deen67 » Thu Feb 09, 2012 6:06 pm

BillyBoyo wrote:deen67, are you processing a file of what was DFHCOMMAREA or are you doing it in CICS?


yes, got the file from DFHCOMMAREA. at the moment i'm using enrico's method. it's works. managed to split the var part but still try to figure out how to use unstring verb. thanks for those who helped me.

just a question for unstring syntax, want to know is't valid or not in cobol. let's say the string contains like this
STRING1 = "CMNOW_REF_NO=1820101010101~CMNOW_CATEGORY=1~CMNOW_NEW_ID=820101010101~CMNOW_OLD_ID=A181814~CMNOW_POLICE_ID=X"

01. String1.
05 Temp-col-val occurs pic x(100) occurs 10 times

perform varying ctr1 until < length of STRING1
add 1 to ctr1
unstring string1 delimited by '~'
into temp-col-val(ctr1)
end-perform

will my output like this
temp-col-val(1) = CMNOW_REF_NO=1820101010101
temp=col-val(2) = CMNOW_CATEGORY=1
temp-col-val(3) = CMNOW_NEW_ID=820101010101
and bla bla bla


is there any possible to use 1 unstring command to get output like this from STRING1
temp-col(1)=CMNOW_REF_NO
temp-val(1)=1820101010101
temp-col(2)=CMNOW_CATEGORY
temp-val(2)=1
temp-col(3)=CMNOW_NEW_ID
temp-val(3)=820101010101
deen67
 
Posts: 10
Joined: Mon Jul 11, 2011 2:47 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Give me some ideas .. how to solve this problem

Postby BillyBoyo » Thu Feb 09, 2012 6:42 pm

deen67 wrote:[...]
just a question for unstring syntax, want to know is't valid or not in cobol. let's say the string contains like this
STRING1 = "CMNOW_REF_NO=1820101010101~CMNOW_CATEGORY=1~CMNOW_NEW_ID=820101010101~CMNOW_OLD_ID=A181814~CMNOW_POLICE_ID=X"

01. String1.
05 Temp-col-val occurs pic x(100) occurs 10 times

perform varying ctr1 until < length of STRING1
add 1 to ctr1
unstring string1 delimited by '~'
into temp-col-val(ctr1)
end-perform

will my output like this
temp-col-val(1) = CMNOW_REF_NO=1820101010101
temp=col-val(2) = CMNOW_CATEGORY=1
temp-col-val(3) = CMNOW_NEW_ID=820101010101
and bla bla bla


is there any possible to use 1 unstring command to get output like this from STRING1
temp-col(1)=CMNOW_REF_NO
temp-val(1)=1820101010101
temp-col(2)=CMNOW_CATEGORY
temp-val(2)=1
temp-col(3)=CMNOW_NEW_ID
temp-val(3)=820101010101


There are two better methods to answer at least part of your question. Toss the code into the compiler. This method is infallible for syntax. Look at the manual first. This is fallible, but usually followed by the previous anyway.

However, it is possible. to have correct syntax and invalid logic. To use the Unstring in a loop, you need to know where you got to on the previous attempt. Unstring is not doing anything to the source, so if you code like that you will constantly get the same result.

Yes, you can do it the second way. You just have to code it all out, and make sure they are iniitalised (can be to the group item) before the Unstring, as Unstring is going to do nothing to fields it has not used on that occasion.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: Give me some ideas .. how to solve this problem

Postby Robert Sample » Thu Feb 09, 2012 6:44 pm

Think of UNSTRING as similar to MOVE. MOVE makes a copy of the data in the source variable but does not change it. Similarly, UNSTRING makes a copy of the source data but does not change it. Hence, unless you do something to your source variable after each UNSTRING statement, your loop will unstring the exact same data each time it runs. Why? Because each UNSTRING statement starts at the first byte of the variable and proceeds until the condition(s) is (are) met -- or the source variable length is reached.
Robert Sample
Global moderator
 
Posts: 3535
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 252 times

Re: Give me some ideas .. how to solve this problem

Postby deen67 » Fri Feb 17, 2012 5:47 pm

thanks everyone for replying. problem solved by using reference modification. although the code quite long but it works. thanks again. :)
deen67
 
Posts: 10
Joined: Mon Jul 11, 2011 2:47 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Give me some ideas .. how to solve this problem

Postby greenorange » Tue Feb 21, 2012 11:58 am

This is all quite new to me and this post actually opened my eyes.Thanks for sharing with us your wisdom.
greenorange
 
Posts: 1
Joined: Tue Feb 14, 2012 7:19 am
Has thanked: 0 time
Been thanked: 0 time

Re: Give me some ideas .. how to solve this problem

Postby meensraji » Tue Feb 21, 2012 12:52 pm

After you read the record, use inspect with tallying option to count the no of '=' in the variable part of the record and move the count to the depending on option of array.

Then use the array with depending on option to move the column name/value to the array variables.

03 REC-1.
05 FIELD-1 PIC 9.
05 FIELD-2 OCCURS 1 TO 5 TIMES
DEPENDING ON FIELD-1 PIC X(05).


Based on the FIELD-1 value, the array size is varied.

Correct me if im wrong
meensraji
 
Posts: 2
Joined: Tue Feb 21, 2012 12:44 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Give me some ideas .. how to solve this problem

Postby BillyBoyo » Tue Feb 21, 2012 1:11 pm

That would work if each value, including the delmiting comma, were only exactly five bytes long. If not, then it won't.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Previous

Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post