Skip to Content
author's profile photo Former Member
Former Member

file format coantaining header and item

hi,

my requirement is to upload flat file without delimiter which contains header and item data using bapi.

in my file i have indicator H for header and for item it is space like below

H fld1 fld2 fld3

fld4 fld5

fld4 fld5

H fld1 fld2 fld3

fld4 fld5

how to take this fields into internal table from flat file?

and upto row 3 in above file i hav to send it to bapi function module as header and item details.so, that it shuld create one purchase order.and from row 4 upto next H i shuld send it to bapi as another record for second purchase order.

how to do it?

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Dec 19, 2008 at 06:31 AM

    H fld1 fld2 fld3

    fld4 fld5

    fld4 fld5

    H fld1 fld2 fld3

    fld4 fld5

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 19, 2008 at 08:50 AM

    Hi,

    Create a work area and an internal table for a file to extract the contains of your flat file.

    data : begin of wa_file,

    text(150) type c,

    end of wa_file.

    data : it_file like standard table of wa_file.

    Also declare a data abject to hold ur record indicator like below to hold your value Eg : HD.

    data : v_id(2).

    Now you need to split your contents like below.

      loop at it_file into wa_file.
        if wa_file+0(2) = 'HD'.      " Header
          split wa_file at ',' into v_id
              wa-fld1,
              wa-fld2,  
              wa-fld3.
          append wa to it.
        elseif wa_file+0(2) = 'BD'.      " Body data
          split wa_file at ','  into v_id
            wa-fld4,
            wa-fld5.
           append wa to i.
        endif.
        endloop.
    
    

    Hope this would hep you.

    Regards,

    Ranjith N.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.