Skip to Content
0
Former Member
Jul 20, 2007 at 03:37 PM

READ THE PIPE DELIMITER FILE

30 Views

Hi guys,

I am uploading the data from a file which is in the application server and in pipe delimiter format.

This file in the format like .... let us take 100 records among those one record is header, 98 data records and one trailer record. These are seperated by the record locater like header with 0, data record with 1 and trailer with 9.

So what i am doing is uploading that file first of all into one internal table I_ARFILE, then splitting the data at pipe into 3 different internal tables. In the mean time I am doing the validations also for the number of records...

like there should not be more than one header, and one trailer........

here I am pasting my code.....

IF l_subrc = 0.

LOOP AT I_ARFILE.

READ TABLE I_ARFILE INTO WA_ARFILE.

SPLIT WA_ARFILE AT C_PIPE INTO WA_ARHEADER-P_RECTYPE

WA_ARHEADER-P_PRCID

WA_ARHEADER-P_SENDR

WA_ARHEADER-P_CDATE

WA_ARHEADER-P_CTIME

WA_ARHEADER-P_OBTYP

WA_ARHEADER-P_SEQNO

WA_ARHEADER-P_FRTXT.

IF WA_ARHEADER-P_RECTYPE = 0.

APPEND WA_ARHEADER TO I_ARHEADER.

DESCRIBE TABLE I_ARHEADER LINES V_ITABLINES.

  • VALIDATION FOR NUMBER OF HEADER RECORDS

IF V_ITABLINES <> 1.

MESSAGE 'NUMBER OF LINES READ ARE NOT SAME' TYPE 'E'.

LEAVE PROGRAM.

ENDIF.

CLEAR V_ITABLINES.

ELSE.

SPLIT I_ARFILE AT C_PIPE

INTO WA_ARITEM-P_RECTYPE

WA_ARITEM-p_xblnr

WA_ARITEM-p_bldat

WA_ARITEM-p_budat

WA_ARITEM-p_blart

WA_ARITEM-p_awkey

WA_ARITEM-p_kunnr

WA_ARITEM-p_xref1

WA_ARITEM-p_xref2

WA_ARITEM-p_xref3

WA_ARITEM-p_wrbtr

WA_ARITEM-p_zterm

WA_ARITEM-p_zuonr

WA_ARITEM-p_rstgr

WA_ARITEM-p_wskto

WA_ARITEM-p_sgtxt.

IF WA_ARITEM-P_RECTYPE = 1.

APPEND WA_ARITEM TO I_ARITEM.

  • ENDIF.

  • VALIDAITON FOR THE NUMBER OF DATA RECORDS.

DESCRIBE TABLE I_ARITEM LINES V_ITABLINES.

DESCRIBE TABLE I_ARFILE LINES V_ITABLINES1.

V_ITABLINES1 = V_ITABLINES1 - 2.

IF V_ITABLINES1 <> V_ITABLINES.

MESSAGE 'NUMBER OF LINES READ ARE NOT SAME' TYPE 'E'.

LEAVE PROGRAM.

ENDIF.

LOOP AT I_ARITEM.

V_BAL1 = V_BAL1 + I_ARITEM-P_WRBTR.

V_DIS = V_DIS + I_ARITEM-P_WSKTO.

ENDLOOP.

  • CHECKING THE SUM OF THE BALANCE AMOUNT OF ALL THE RECORDS AND BALANCE AMOUNT IN TRAILER RECORD

IF V_BAL1 <> WA_ARTRAILER-TOBAL.

MESSAGE 'TOTAL AMOUNT IS NOT EQUAL TO THE SUM OF ALL THE AMOUNTS' TYPE 'E'.

ELSE.

  • CHECKING THE SUM OF THE DISCOUNT AMOUNT OF ALL THE RECORDS AND BALANCE AMOUNT IN TRAILER RECORD

IF V_DIS <> WA_ARTRAILER-TODIS.

MESSAGE 'TOTAL DISCOUNT AMOUNT IS NOT EQUAL TO THE SUM OF ALL THE DISCOUNT AMOUNTS' TYPE 'E'.

ENDIF.

CLEAR V_BAL1.

  • APPEND WA_ARITEM TO I_ARITEM.

CLEAR WA_ARITEM.

  • CLEAR WA_ARFILE.

CLEAR V_ITABLINES.

CLEAR V_ITABLINES1.

  • ENDIF.

  • ENDLOOP.

  • ENDLOOP.

  • ENDIF.

ELSE.

  • READ TABLE I_ARFILE INTO WA_ARFILE INDEX V_ITABLINES.

SPLIT WA_ARFILE AT C_PIPE INTO WA_ARTRAILER-P_RECTYPE

WA_ARTRAILER-COUNT

WA_ARTRAILER-TOBAL

WA_ARTRAILER-TODIS.

IF WA_ARTRAILER-P_RECTYPE = 9.

APPEND WA_ARTRAILER TO I_ARTRAILER.

ENDIF.

DESCRIBE TABLE I_ARTRAILER LINES V_ITABLINES.

IF V_ITABLINES <> 1.

MESSAGE 'NUMBER OF LINES READ ARE NOT SAME' TYPE 'E'.

LEAVE PROGRAM.

ENDIF.

  • CLEAR WA_ARFILE.

CLEAR V_ITABLINES.

ENDIF.

*CLEAR WA_ARFILE.

CLEAR V_ITABLINES.

CLEAR V_ITABLINES1.

ENDIF.

ENDLOOP.

In this code something wrong like....

I have to modify this code so that i can split the file based on the record indicator to different internal tables.

if you see my code I am going wrong after i split the data into header internal table... did the validations then I put the else condition and split the same record again into 2nd internal table. But I have to take the second record once the first one is filled..........

Can any one guide me how to do that plz...... I am bit confused with this

SRI

.