View previous topic :: View next topic
|
Author |
Message |
sandeep kumar302
New User
Joined: 14 Mar 2012 Posts: 81 Location: India
|
|
|
|
Hi,
I am writing a cobol program:
Input: CLASS-CODE-FILE vsam file
INPUT-SELL-PRICE-FILE sequential
INPUT-AMAZON-CNTL-FILE - this is control file
output:OUTPUT-SELL-PRICE-FILE sequentil file
Purpose:
Pick class-codes from the control file and load to an array. Then read sell-price file sequentially. For every record - pick 7 digit item code and check in class-code vsam file. If class-code matches to input control card then need to write the record.
Following condition can occur:
No match in Vsam --- Drop the record.
Match in Vsam --- write the record in output. For multiple matches for same item, repeat the record in the output file. While writing the record please initialize the store-nbr field.
I have written the cobol program but the issue is that the VSAM file will be having multiple matching class codes for the same TB and Item code value but the output file is having only the 1st matching record.
Code: |
*---------------------------*
1100-READ-CONTROL-FILE.
*---------------------------*
MOVE '1100-READ-CONTROL-FILE' TO WS-PARANAME
D DISPLAY WS-PARANAME
READ INPUT-AMAZON-CNTL-FILE
NOT AT END
MOVE I-AMZ-CLASS-CODE
TO WS-CNTL-CLASS-CODE(WS-CNTL-IDX)
SET WS-CNTL-IDX UP BY 1
ADD 1 TO WS-I-AMZ-CNTL-REC-CNT
END-READ
.
*--------------------------------*
|
In the above para, i am reading the control file and loading in the temporary array
In the below para, i am validating the class code and then further writing to the output file:
Code: |
*----------------------------------*
2100-VALIDATE-CLASS-CODE.
*----------------------------------*
MOVE '2100-VALIDATE-CLASS-CODE' TO WS-PARANAME
D DISPLAY WS-PARANAME
MOVE ISL-PRC-ITEM-TB TO IFCLASS-TYPE-BUS-CODE
MOVE ISL-PRC-ITEM-CODE TO IFCLASS-BITEM-CODE
MOVE ZEROS TO IFCLASS-DEAL
IFCLASS-PACK
IFCLASS-CODE
MOVE LOW-VALUES TO IFCLASS-COMPONENT-CODE
IFCLASS-LEVEL-CODE
IFCLASS-WHSE-CODE
SET NO-MATCH-FOUND TO TRUE
START CLASS-CODE-FILE KEY GREATER THAN IFCLASS-KEY
EVALUATE WS-ICLASSCD-FS
WHEN '00'
PERFORM UNTIL WS-ICLASSCD-FS > '00'
READ CLASS-CODE-FILE NEXT
NOT AT END
IF ISL-PRC-ITEM-TB = IFCLASS-TYPE-BUS-CODE AND
ISL-PRC-ITEM-CODE = IFCLASS-BITEM-CODE
SET WS-CNTL-IDX TO 1
SEARCH WS-CONTROL-FILE-DATA
AT END
DISPLAY 'SEARCH ELEMENT NOT FOUND IN TBL:'
WHEN WS-CNTL-CLASS-CODE(WS-CNTL-IDX) =
IFCLASS-CODE
SET MATCH-FOUND TO TRUE
END-SEARCH
ELSE
SET C-ICLASSCD-NOTFND TO TRUE
END-IF
END-READ
END-PERFORM
WHEN OTHER
CONTINUE
END-EVALUATE
IF NO-MATCH-FOUND
SET DROP-RECORD TO TRUE
END-IF
.
|
In the above para, if MATCH-FOUND is true then i am writing to output file
I guess the issue is from:
Code: |
IF ISL-PRC-ITEM-TB = IFCLASS-TYPE-BUS-CODE AND
ISL-PRC-ITEM-CODE = IFCLASS-BITEM-CODE
SET WS-CNTL-IDX TO 1
SEARCH WS-CONTROL-FILE-DATA
AT END
DISPLAY 'SEARCH ELEMENT NOT FOUND IN TBL:'
WHEN WS-CNTL-CLASS-CODE(WS-CNTL-IDX) =
IFCLASS-CODE
SET MATCH-FOUND TO TRUE
END-SEARCH
ELSE
SET C-ICLASSCD-NOTFND TO TRUE
END-IF
|
Can someone help me in rectifying this |
|
Back to top |
|
|
sandeep kumar302
New User
Joined: 14 Mar 2012 Posts: 81 Location: India
|
|
|
|
The issue is that if the key(TB + Item code) from sell price file is matching with (TB+ Item code) value from VSAM file(Key is TB+ ITem code+ shc id) , then the class code will be searched in the table and if it matches, then output is written which is happening correctly.
It is also possible that for the same sell price records, there can be multiple records with same TB+ Item combination in the VSAM file and for every matching record, there should be one output record.
But, i am not getting all the records in the output file. |
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3053 Location: NYC,USA
|
|
|
|
I strongly suggest you to add display's and use only few records in input file for testing purpose and then you can figure it out by yourself where is the problem very easily than just looking at the code. If you have any debugger , please make a use of that one. While you do so others here can also give you a clue of what has went wrong. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Without the data-defintions shown to us, there may well be more than one thing which needs changing.
However, one bit is easy: you don't do anything in the (PERFORM) loop to write records, so at most you'll only ever get one. |
|
Back to top |
|
|
sandeep kumar302
New User
Joined: 14 Mar 2012 Posts: 81 Location: India
|
|
|
|
Hi Rohit/Bill,
Thanks for your suggesions.
I did some small change the program and it worked fine. It was the issue with not setting the index properly.
If you guys want it, i can put the code here for all of us to see. |
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3053 Location: NYC,USA
|
|
|
|
Yes please <with the tags>. |
|
Back to top |
|
|
|