<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic CSV file read in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/csv-file-read/m-p/2467679#M554349</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Experts&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hopefully you can help me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am reading a flat file using GUI_UPLOAD, splitting the file, then using another function module to load the data. The data is loading succesfully. However, all of the lines are loading under one header record. An example of the file format is :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Header 	bud cat	doctype	version	fm area	docstate	process	fund 	fund center	cmmt item&lt;/P&gt;&lt;P&gt;H 	9F	2	ZBW	9000	1	ENTR	DEF	A00	RM09&lt;/P&gt;&lt;P&gt;L	9F	2	ZBW	9000	1	ENTR	DEF	A00	RM09&lt;/P&gt;&lt;P&gt;H	9F	2	ZBW	9000	1	ENTR	DEF	A00	RM09&lt;/P&gt;&lt;P&gt;L	9F	2	ZBW	9000	1	ENTR	DEF	A00	RM09&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need to read the file, create the header record then create a line record (denoted by L). When the a new header record is found (H) create a new header and add the lines). At the moment its creating all the lines under one header.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thank you for your help&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 22 Jun 2007 08:21:17 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-06-22T08:21:17Z</dc:date>
    <item>
      <title>CSV file read</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/csv-file-read/m-p/2467679#M554349</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Experts&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hopefully you can help me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am reading a flat file using GUI_UPLOAD, splitting the file, then using another function module to load the data. The data is loading succesfully. However, all of the lines are loading under one header record. An example of the file format is :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Header 	bud cat	doctype	version	fm area	docstate	process	fund 	fund center	cmmt item&lt;/P&gt;&lt;P&gt;H 	9F	2	ZBW	9000	1	ENTR	DEF	A00	RM09&lt;/P&gt;&lt;P&gt;L	9F	2	ZBW	9000	1	ENTR	DEF	A00	RM09&lt;/P&gt;&lt;P&gt;H	9F	2	ZBW	9000	1	ENTR	DEF	A00	RM09&lt;/P&gt;&lt;P&gt;L	9F	2	ZBW	9000	1	ENTR	DEF	A00	RM09&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need to read the file, create the header record then create a line record (denoted by L). When the a new header record is found (H) create a new header and add the lines). At the moment its creating all the lines under one header.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thank you for your help&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Jun 2007 08:21:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/csv-file-read/m-p/2467679#M554349</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-22T08:21:17Z</dc:date>
    </item>
    <item>
      <title>Re: CSV file read</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/csv-file-read/m-p/2467680#M554350</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Andrew&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I assume you have the header/line marker in the records of your data itab. Thus, you could us the following logic:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;  DATA: ld_idx       TYPE 1.

  LOOP AT lt_itab INTO ls_record
                           WHERE ( header = 'H' ).
    ld_idx = syst-tabix + 1.

"   Read all lines for header
    LOOP AT lt_itab INTO ls_record_x FROM ld_idx.
      IF ( ls_record_x-header ne 'L' ).
        EXIT.  " leave loop
      ENDIF.

"     collect lines for header
...
    ENDLOOP.
"   Ignore header if it has no lines???
    IF ( syst-subrc ne 0 ).
...
    ENDIF.

  ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;  Uwe&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Jun 2007 08:41:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/csv-file-read/m-p/2467680#M554350</guid>
      <dc:creator>uwe_schieferstein</dc:creator>
      <dc:date>2007-06-22T08:41:09Z</dc:date>
    </item>
    <item>
      <title>Re: CSV file read</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/csv-file-read/m-p/2467681#M554351</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the reply ewe&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;still having a problem..attached is my code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  DATA: ld_idx. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  LOOP AT t_data INTO st_data&lt;/P&gt;&lt;P&gt;                           WHERE ( HEAD_IND = 'H' ).&lt;/P&gt;&lt;P&gt;    ld_idx = syst-tabix + 1.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  Read all lines for header&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  LOOP AT t_data INTO st_data FROM ld_idx.&lt;/P&gt;&lt;P&gt;      IF ( st_data-head_ind ne 'L' ).&lt;/P&gt;&lt;P&gt;        EXIT.  " leave loop&lt;/P&gt;&lt;P&gt;      ENDIF.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;    IF st_data IS INITIAL.&lt;/P&gt;&lt;P&gt;      CONTINUE.&lt;/P&gt;&lt;P&gt;    ENDIF.&lt;/P&gt;&lt;P&gt;    ADD 1 TO w_item.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    w_recs_in = w_recs_in + 1.&lt;/P&gt;&lt;P&gt;    w_tabix = sy-tabix.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    st_period-item_num = w_item.&lt;/P&gt;&lt;P&gt;    PERFORM store_period USING '1'  st_data-per01.&lt;/P&gt;&lt;P&gt;    PERFORM store_period USING '2'  st_data-per02.&lt;/P&gt;&lt;P&gt;    PERFORM store_period USING '3'  st_data-per03.&lt;/P&gt;&lt;P&gt;    PERFORM store_period USING '4'  st_data-per04.&lt;/P&gt;&lt;P&gt;    PERFORM store_period USING '5'  st_data-per05.&lt;/P&gt;&lt;P&gt;    PERFORM store_period USING '6'  st_data-per06.&lt;/P&gt;&lt;P&gt;    PERFORM store_period USING '7'  st_data-per07.&lt;/P&gt;&lt;P&gt;    PERFORM store_period USING '8'  st_data-per08.&lt;/P&gt;&lt;P&gt;    PERFORM store_period USING '9'  st_data-per09.&lt;/P&gt;&lt;P&gt;    PERFORM store_period USING '10' st_data-per10.&lt;/P&gt;&lt;P&gt;    PERFORM store_period USING '11' st_data-per11.&lt;/P&gt;&lt;P&gt;    PERFORM store_period USING '12' st_data-per12.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;no period data&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    IF st_data+150(360) IS INITIAL.&lt;/P&gt;&lt;P&gt;      st_item-total_amount = st_data-total.&lt;/P&gt;&lt;P&gt;      st_item-distkey      = st_data-distkey.&lt;/P&gt;&lt;P&gt;    ELSE.&lt;/P&gt;&lt;P&gt;      CLEAR st_item-total_amount.&lt;/P&gt;&lt;P&gt;      CLEAR st_item-distkey.&lt;/P&gt;&lt;P&gt;    ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;set up the static header data&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    st_header-fm_area  = st_data-fm_area.&lt;/P&gt;&lt;P&gt;    st_header-docdate  = p_dcdate.&lt;/P&gt;&lt;P&gt;    st_header-doctype  = st_data-doctype.&lt;/P&gt;&lt;P&gt;    st_header-docstate = st_data-docstate.&lt;/P&gt;&lt;P&gt;    st_header-process  = st_data-process.&lt;/P&gt;&lt;P&gt;    w_year = '2007'.&lt;/P&gt;&lt;P&gt;    st_header-version = st_data-version.&lt;/P&gt;&lt;P&gt;    w_budtype = st_data-budtype.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;other header data&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    st_header_add-header_text = p_htext.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;other item data&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    st_item-item_num   = w_item.&lt;/P&gt;&lt;P&gt;    st_item-fisc_year  = w_year.&lt;/P&gt;&lt;P&gt;    st_item-budcat     = st_data-budcat.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  st_item-func_area  = p_func.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    st_item-trans_curr = st_data-trans_curr.&lt;/P&gt;&lt;P&gt;    st_item-item_text  = p_ltext.&lt;/P&gt;&lt;P&gt;    st_item-valtype    = st_data-valtype.&lt;/P&gt;&lt;P&gt;    st_item-fund       = st_data-fund.&lt;/P&gt;&lt;P&gt;    st_item-funds_ctr  = st_data-funds_ctr.&lt;/P&gt;&lt;P&gt;    st_item-cmmt_item  = st_data-cmmt_item.&lt;/P&gt;&lt;P&gt;    st_item-measure    = st_data-measure.&lt;/P&gt;&lt;P&gt;    st_item-grant_nbr  = st_data-grant_nbr.&lt;/P&gt;&lt;P&gt;    st_item-budtype    = w_budtype.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    APPEND st_item TO t_item.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Validate the data. This is done in the BAPI (via BAdI&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;FMKU_BEDGET_EVNT_CC) but the errors are not presented&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;in a user-friendly manner on the report&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    PERFORM validate_record CHANGING w_error.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDFORM.                    " process_records&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Jun 2007 11:02:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/csv-file-read/m-p/2467681#M554351</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-22T11:02:57Z</dc:date>
    </item>
  </channel>
</rss>

