View previous topic :: View next topic
|
Author |
Message |
sid_aec
New User
Joined: 01 Jul 2008 Posts: 60 Location: Kolkata
|
|
|
|
Hi,
I have a data looks as below:
00BDXXX,00XXSM,00XXMSM,00YYAMSM,00YYSM
50 such parameters will be passed to a stored proc.
I want to finally make a table pouplated with this data as below:
01 data-table occurs 50 times
05 num pic s9(4) comp.
05 char pic x(06)
As the values could be of 7 bytes or 8 bytes and I need to put it into a table of 8 bytes field as shown above.
Could you please help me how to achieve it..
Thanking you, |
|
Back to top |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
What have you tried so far? Where are you stuck? |
|
Back to top |
|
|
karisurya
New User
Joined: 02 Aug 2007 Posts: 64 Location: Bangalore
|
|
|
|
Quote: |
I have a data looks as below:
00BDXXX,00XXSM,00XXMSM,00YYAMSM,00YYSM
|
I guess you are trying to tell first 2 bytes are numeric and remaining alphanumeric, Every one can interpret the input in there own way so its good if you can define your input clearly.
Quote: |
50 such parameters will be passed to a stored proc.
|
Can you explain the above statement? Just to understand how you are passing data to Program.
Quote: |
01 data-table occurs 50 times
05 num pic s9(4) comp.
05 char pic x(06)
|
As per my knowledge we cant define working storage like this.....
Conclusion:
Refine your requirement state clearly your Input/Output and where you are facing trouble in coding which will help you to get quick responses. |
|
Back to top |
|
|
viveksurya
New User
Joined: 08 Jun 2009 Posts: 36 Location: Bangalore
|
|
|
|
Can you be more elaborate on your requirement and also where are you facing problem in whatever way you are approaching to achieve this.
For the time being, the way you are defining the data-items is incorrect.
Quote: |
01 data-table occurs 50 times
05 num pic s9(4) comp.
05 char pic x(06) |
You cant use OCCURS clause for 01 level number. |
|
Back to top |
|
|
viveksurya
New User
Joined: 08 Jun 2009 Posts: 36 Location: Bangalore
|
|
|
|
Understanding that you want the parameters (having numeric and character part) to be moved to a table, here is a logic:
Code: |
.
.
.
WORKING-STORAGE SECTION.
01 WS-INPUT PIC X(47)
VALUE '00BDXXX,00XXSM,00XXMSM,00YYAMSM,00YYSM,00ZZAHSM'.
01 SAMPLE-TABLE.
05 SAMPLE-1 OCCURS 6 TIMES.
10 SAMPLE-ITEM-1 PIC S9(4) COMP.
10 SAMPLE-ITEM-2 PIC X(06) .
PROCEDURE DIVISION.
A000-MAINLINE.
UNSTRING WS-INPUT DELIMITED BY ","
INTO SAMPLE-1(1), SAMPLE-1(2), SAMPLE-1(3),
SAMPLE-1(4), SAMPLE-1(5), SAMPLE-1(6)
DISPLAY "SAMPLE-1 =" SAMPLE-1(1)
DISPLAY "SAMPLE-2 =" SAMPLE-1(2)
DISPLAY "SAMPLE-3 =" SAMPLE-1(3)
DISPLAY "SAMPLE-4 =" SAMPLE-1(4)
DISPLAY "SAMPLE-5 =" SAMPLE-1(5)
DISPLAY "SAMPLE-6 =" SAMPLE-1(6).
.
.
.
|
Output:
Code: |
SAMPLE-1 =00BDXXX
SAMPLE-2 =00XXSM
SAMPLE-3 =00XXMSM
SAMPLE-4 =00YYAMSM
SAMPLE-5 =00YYSM
SAMPLE-6 =00ZZAHSM |
PS: I have taken here 6 parameters which will be 50 in your case.
Hope this helps. |
|
Back to top |
|
|
sid_aec
New User
Joined: 01 Jul 2008 Posts: 60 Location: Kolkata
|
|
|
|
viveksurya,
Exactly this is I required.I also able to make it for 5 times,but my requirement is for 50 times.
Do I need to use hard code like 'SAMPLE-1(1), SAMPLE-1(2), SAMPLE-1(3), SAMPLE-1(4), SAMPLE-1(5), SAMPLE-1(6) ..
Because for 50 times,hardcoding all occurance requires more coding effort.
Is there anyother way I can make it instead of hardcoding all occurances..
Please advise if possible..
Thanks,
Siddhartha.. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Siddhartha wrote: |
Because for 50 times,hardcoding all occurance requires more coding effort. |
suggest that you look at the UNSTRING statement in a cobol reference manual.
any loop that you write to separately UNSTRING each item would take longer to execute than a single UNSTRING into the 50 receiving items.
in fact, in the time you took to post your whine about having to do so much extra work, you could have coded the 50 separate references.
[Personal opinion on]
I wish that you had 1000 occurances.
[Personal opinion off] |
|
Back to top |
|
|
viveksurya
New User
Joined: 08 Jun 2009 Posts: 36 Location: Bangalore
|
|
|
|
As Dick mentioned, UNSTRING would take more time as the no. of occurances increases.
Quote: |
Do I need to use hard code like 'SAMPLE-1(1), SAMPLE-1(2), SAMPLE-1(3), SAMPLE-1(4), SAMPLE-1(5), SAMPLE-1(6) .. |
You can use subscript to refer to each occurance. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Vivek,
the lazy TS did not want to code each of the 50 receiving fields in the UNSTRING.
absolute indexing (1, 2 , 4 etc..) is the fastest.
using subscripts or indexing would cause more code to be generated by the compiler.
and I didn't say (even though it is true) that more receiving fields in an UNSTRING would involve more time to execute.
what I did say was that any loop constructed so as to save this poor coder time in writing his program would cause a lot of extra execution time. |
|
Back to top |
|
|
|