Page 2 of 2

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

PostPosted: Thu Feb 09, 2012 4:56 pm
by ronners
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.

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

PostPosted: Thu Feb 09, 2012 5:04 pm
by BillyBoyo
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.

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

PostPosted: Thu Feb 09, 2012 6:06 pm
by deen67
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

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

PostPosted: Thu Feb 09, 2012 6:42 pm
by BillyBoyo
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.

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

PostPosted: Thu Feb 09, 2012 6:44 pm
by Robert Sample
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.

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

PostPosted: Fri Feb 17, 2012 5:47 pm
by deen67
thanks everyone for replying. problem solved by using reference modification. although the code quite long but it works. thanks again. :)

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

PostPosted: Tue Feb 21, 2012 11:58 am
by greenorange
This is all quite new to me and this post actually opened my eyes.Thanks for sharing with us your wisdom.

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

PostPosted: Tue Feb 21, 2012 12:52 pm
by meensraji
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

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

PostPosted: Tue Feb 21, 2012 1:11 pm
by BillyBoyo
That would work if each value, including the delmiting comma, were only exactly five bytes long. If not, then it won't.