I am using COBOL file as source where 01 level groups are two. Following are the details.
In Output file first and last row are required and middle two rows are extra. Am I missing any setting or there is some other error.
Input data File:
2014001100450005000000001141107TD2798600000200120011201400090029+000000000024850+000000000000000+000000000000000000CATALOG SCTEST TEST 12 MAIN ST HINGHAM MA **********-111-111100000000000000000000000000000000000000000000000040000000000000001 0000 00000002786354800000000000000064486448
2015001000440007123456789123456789ABCD301088+123456789+1234567891234123456789ABCDEZZ1234ABCD12341234567890ABCDEFBCD**********ABCDEF12341234
OutPut file:
2014,11,45,5,2014001,100450005,1,141107TD27986,14,1107T,D27986,141107,TD,279,86,000,002,12,11,2014,9,29,248.50,0.00,0.000000000,CATALOG, , , ,SC,TEST TEST , ,12 MAIN ST ,HINGHAM ,MA ,020430000,2043,0,020430,000,111-111-1111,0,0,0,0,0,0,4,0,0,0,1, ,0, ,27863548,0,6448,6448
,2014,11,45,5,2014001,100450005,1,141107TD27986,14,1107T,D27986,141107,TD,279,86,000,002,120011.20,14000900.29,0,24,24,24,24,24,850+0,0,0,00000000,0,+000000000000000,000CATALOG SCTES,,
2015,10,44,7,2015001,440007,123456789,123456789ABCD,12,34567,89ABCD,123456,78,9AB,CD,301,088,123,4567,8901,2345,6789,,,,1234567,8,9,0A,BC,DEF1234123,4,,,,,,,,,,,,,,,,,,,,,,,,,,,,
2015,10,44,7,2015001,440007,123456789,123456789ABCD,12,34567,89ABCD,123456,78,9AB,CD,301,088,1234567.89,1234567.89,1234,123456789,123456789,123456789,123456789,123456789,ABCDE,Z,Z,1234ABCD,1234,**********ABCDEF,BCD**********ABCDEF,1234,1234
Desired Output:
2014,11,45,5,2014001,100450005,1,141107TD27986,14,1107T,D27986,141107,TD,279,86,000,002,12,11,2014,9,29,248.50,0.00,0.000000000,CATALOG, , , ,SC,TEST TEST , ,12 MAIN ST ,HINGHAM ,MA ,020430000,2043,0,020430,000,111-111-1111,0,0,0,0,0,0,4,0,0,0,1, ,0, ,27863548,0,6448,6448
2015,10,44,7,2015001,440007,123456789,123456789ABCD,12,34567,89ABCD,123456,78,9AB,CD,301,088,1234567.89,1234567.89,1234,123456789,123456789,123456789,123456789,123456789,ABCDE,Z,Z,1234ABCD,1234,**********ABCDEF,BCD**********ABCDEF,1234,1234
Source File:
environment division.
select SAHDR-SAADMIN assign to "fname".
data division.
file section.
fd SAHDR-SAADMIN.
01 STSHDR-RECORD.
05 SAHDR-KEY.
10 SAHDR-FISCAL-POSTING-DATE.
15 SAHDR-FISCAL-YEAR PIC 9(04).
15 SAHDR-FISCAL-MONTH PIC 9(04).
15 SAHDR-FISCAL-WEEK PIC 9(04).
15 SAHDR-FISCAL-DAY PIC 9(04).
10 SAHDR-RELATIVE-DATE
REDEFINES SAHDR-FISCAL-POSTING-DATE.
15 SAHDR-DAY-IDNT PIC 9(07).
15 SAHDR-FILLER PIC 9(09).
10 SAHDR-STORE-NUMBER PIC 9(09).
10 SAHDR-TRANSACTION-NUMBER-KEY PIC X(13).
10 SAHDR-TRANSACTION-NUMBER
REDEFINES SAHDR-TRANSACTION-NUMBER-KEY.
15 SAHDR-REGISTER-NUMBER PIC X(02).
15 SAHDR-TRANS-NUMBER PIC X(05).
15 SAHDR-TRANS-SORT PIC X(06).
10 SAHDR-MO-TRANS-NUMBER
REDEFINES SAHDR-TRANSACTION-NUMBER-KEY.
15 SAHDR-MO-ORDER-DATE PIC X(06).
15 SAHDR-MO-DEPT-CLERK PIC X(02).
15 SAHDR-MO-ORDER-BATCH PIC X(03).
15 SAHDR-MO-ORDER-SEQ-NUMBER PIC X(02).
10 SAHDR-RECORD-TYPE PIC X(03).
88 SAHDR-HEADER-RECORD VALUE '000'.
10 SAHDR-TRANS-TYPE PIC X(03).
88 SAHDR-SALE-TRANSACTION VALUE '001'.
05 SAHDR-DATA.
10 SAHDR-TRANSACTION-DATE.
15 SAHDR-CALENDAR-MONTH PIC 9(04).
15 SAHDR-CALENDAR-DAY PIC 9(04).
15 SAHDR-CALENDAR-YEAR PIC 9(04).
10 SAHDR-TRANSACTION-TIME.
15 SAHDR-REG-TRANS-HOUR PIC 9(04).
15 SAHDR-REG-TRANS-MINUTE PIC 9(04).
10 SAHDR-TOTAL-TRANS-AMOUNT PIC +9(13)V99.
10 SAHDR-CONVERSION-TRANS-AMOUNT PIC +9(13)V99.
10 SAHDR-CONVERSION-RATE PIC +9(09)V9(9).
10 SAHDR-TRANS-ORIGIN PIC X(07).
88 SAHDR-POINT-OF-SALE VALUE 'POS '.
88 SAHDR-MAILORDER VALUE 'CATALOG'.
10 SAHDR-TRANS-VOID-DURING-FLAG PIC X(01).
10 SAHDR-TRANS-POST-VOID-FLAG PIC X(01).
10 SAHDR-TRANS-ERROR-CODE PIC X(02).
88 SAHDR-NO-ERRORS VALUE '00'.
10 SAHDR-RFS-LOCATION-TYPE PIC X(02).
10 SAHDR-CUSTOMER-NAME.
15 SAHDR-CUSTOMER-FNAME PIC X(10).
15 SAHDR-CUSTOMER-LNAME PIC X(20).
10 SAHDR-CUSTOMER-ADDRESS PIC X(35).
10 SAHDR-CUSTOMER-CITY PIC X(25).
10 SAHDR-CUSTOMER-STATE PIC X(03).
10 SAHDR-CUSTOMER-ZIPCODE PIC X(09).
10 SAHDR-USA-ZIPCODE
REDEFINES SAHDR-CUSTOMER-ZIPCODE.
15 SAHDR-CUSTOMER-FIRST-FIVE PIC 9(05).
15 SAHDR-CUSTOMER-LAST-FOUR PIC 9(04).
10 SAHDR-CANADA-ZIPCODE
REDEFINES SAHDR-CUSTOMER-ZIPCODE.
15 SAHDR-CANADA-CUST-ZIP PIC X(06).
15 FILLER PIC X(03).
10 SAHDR-CUSTOMER-PHONE PIC X(12).
10 SAHDR-SALESPERSON.
15 SAHDR-CASHIER PIC 9(07).
15 SAHDR-HEADER-SALESPERSON PIC 9(07).
10 SAHDR-EMPLOYEE-SELLING-NUMBER PIC 9(09).
10 SAHDR-EMPLOYEE-PURCHASE-NUMBER PIC 9(09).
10 SAHDR-SHIPPING-RECORD-NUMBER PIC 9(09).
10 SAHDR-ADMIN-COUNTER PIC 9(04).
10 SAHDR-ITEM-COUNTER PIC 9(04).
10 SAHDR-REGTOT-COUNTER PIC 9(04).
10 SAHDR-STRTOT-COUNTER PIC 9(04).
10 SAHDR-TAXRCD-COUNTER PIC 9(04).
10 SAHDR-TENDER-COUNTER PIC 9(04).
10 SAHDR-USERID PIC X(08).
10 SAHDR-EMP-DEPT PIC 9(04).
10 SAHDR-ERROR-CODE PIC X(01).
10 SAHDR-CUSTOMER-ID PIC 9(15).
10 SAHDR-LOYALTY-ID PIC 9(15).
10 SAHDR-TRANS-TIME.
15 SAHDR-REG-TRANS-HR PIC 9(04).
15 SAHDR-REG-TRANS-MIN PIC 9(04).
01 STSADMIN-RECORD.
05 SAADMIN-KEY.
10 SAADMIN-FISCAL-POSTING-DATE.
15 SAADMIN-FISCAL-YEAR PIC 9(04).
15 SAADMIN-FISCAL-MONTH PIC 9(04).
15 SAADMIN-FISCAL-WEEK PIC 9(04).
15 SAADMIN-FISCAL-DAY PIC 9(04).
10 SAADMIN-RELATIVE-DATE
REDEFINES SAADMIN-FISCAL-POSTING-DATE.
15 SAADMIN-DAY-IDNT PIC 9(07).
15 SAADMIN-FILLER PIC 9(09).
10 SAADMIN-STORE-NUMBER PIC 9(09).
10 SAADMIN-TRANSACTION-NUMBER-KEY PIC X(13).
10 SAADMIN-TRANSACTION-NUMBER
REDEFINES SAADMIN-TRANSACTION-NUMBER-KEY.
15 SAADMIN-REGISTER-NUMBER PIC X(02).
15 SAADMIN-TRANS-NUMBER PIC X(05).
15 SAADMIN-TRANS-SORT PIC X(06).
10 SAADMIN-MO-TRANSACTION-NUMBER
REDEFINES SAADMIN-TRANSACTION-NUMBER-KEY.
15 SAADMIN-MO-ORDER-DATE PIC X(06).
15 SAADMIN-MO-DEPT-CLERK PIC X(02).
15 SAADMIN-MO-ORDER-BATCH PIC X(03).
15 SAADMIN-MO-ORDER-SEQ-NUMBER PIC X(02).
10 SAADMIN-RECORD-TYPE PIC X(03).
88 SAADMIN-ADMINISTRATIVE VALUE '301'.
10 SAADMIN-TRANSACTION-TYPE PIC X(03).
88 SAADMIN-POST-VOID VALUE '088'.
05 SAADMIN-DATA.
10 SAADMIN-AMOUNT PIC +9(07)V99.
10 SAADMIN-CONVERSION-AMOUNT PIC +9(07)V99.
10 SAADMIN-POS-EXPENSE-NUMBER PIC 9(04).
10 SAADMIN-TRANS-ID-NUMBER PIC 9(09).
10 SAADMIN-CHARGE-ACCOUNT-NUMBER REDEFINES
SAADMIN-TRANS-ID-NUMBER PIC 9(09).
10 SAADMIN-GIFT-CERTIFICATE REDEFINES
SAADMIN-TRANS-ID-NUMBER PIC 9(09).
10 SAADMIN-MDSE-CREDIT-NUMBER REDEFINES
SAADMIN-TRANS-ID-NUMBER PIC 9(09).
10 SAADMIN-COUPON-NUMBER REDEFINES
SAADMIN-TRANS-ID-NUMBER PIC 9(09).
10 SAADMIN-ORIGINAL-TRAN-NUMBER PIC X(05).
10 SAADMIN-VOID-DURING-FLAG PIC X(01).
10 SAADMIN-POST-VOID-FLAG PIC X(01).
10 SAADMIN-USERID PIC X(08).
10 SAADMIN-EMP-DEPT PIC 9(04).
10 SAADMIN-GIFT-CARD-NUMBER PIC X(16).
10 SAADMIN-TOKEN-NUMBER PIC X(19).
10 SAADMIN-TRANS-TIME.
15 SAADMIN-REG-TRANS-HR PIC 9(04).
15 SAADMIN-REG-TRANS-MIN PIC 9(04).
working-storage section.
procedure division.
stop run.