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

When upload file on server (AL11) how to break records in multiple lines

Hello Experts,

I've a requirement where I need to upload file on server via AL11. I've records at two levels H1 and D1 and want to upload file same as shown below on server.

H1|00000001|1|N|0000016|C|2A|54|TORONTO|ON||M4M2K2|6456458|876||||||||||2||1|1|2014/10/05| | |

D1|00000001|138035|D|1|0000016|TEST ACCOUNT FOR TESTING|5595 AVEBURY RD|3 FL|MISSISSAUGA|ON||L5R3T8|3367876|514||1| | | | | | |F|NO| |

H1|00000002|1|N|0000016|C|2A|54|TORONTO|ON||M4M2K2|6456458|876||||||||||2||1|1|2014/10/05| | |

D1|00000002|138035|D|1|0000016|TEST ACCOUNT FOR TESTING|5595 AVEBURY RD|3 FL|MISSISSAUGA|ON||L5R3T8|3367876|514||1| | | | | | |F|NO| |

I've saved all the details into two table ( i_zotb_uplift_hdr_err ) and( i_zotb_uplift_dtl_err ) as shown below in the code but the issue is file gets uploaded in a single like

--------------------------------------------------- code -----------------------------------------------------------

loop at i_zotb_uplift_hdr_err into wa_zotb_uplift_hdr_err.
"transfer index H1 record to error file
concatenate 'H1'
wa_zotb_uplift_hdr_err-filenet_id
wa_zotb_uplift_hdr_err-pcl_manifest
wa_zotb_uplift_hdr_err-send_acct
wa_zotb_uplift_hdr_err-send_name
wa_zotb_uplift_hdr_err-send_street

(there are many columns but I don't paste them here)
into lv_line separated by '|'.
transfer lv_line to v_filenamei_err. "transfer wa_zotb_uplift_hdr_err to v_filenamei_err.
if sy-subrc <> 0.
gv_sy_subrc = sy-subrc.
message s158 with v_filenamei_err.
endif.


loop at i_zotb_uplift_dtl_err into wa_zotb_uplift_dtl_err
where filenet_id = wa_zotb_uplift_hdr_err-filenet_id.
"transfer index D1 record to error file
concatenate 'D1'
wa_zotb_uplift_dtl_err-filenet_id
wa_zotb_uplift_dtl_err-posnr
wa_zotb_uplift_dtl_err-ppdtl_order_id
wa_zotb_uplift_dtl_err-zzshipmode
wa_zotb_uplift_dtl_err-zzservice
wa_zotb_uplift_dtl_err-dest_name
wa_zotb_uplift_dtl_err-dest_street
into lv_line separated by '|'.
transfer lv_line to v_filenamei_err. "transfer wa_zotb_uplift_dtl_err to v_filenamei_err.
if sy-subrc <> 0.
gv_sy_subrc = sy-subrc.
message s158 with v_filenamei_err.
endif.
endloop.
endloop.

-----------------------------------------------------------------------------------------------------------------------

------------------------------------------------------------- current output -----------------------------------------------------------------------

H1|7606337593|Y|0000024|CANMADE HARDWARE|8181 RUE EDISON||ANJOU|QC||H1J1S9||000||||||||||001|0|CNVSYEDADE|20141211|205600||00000000|000000|||20141005|D|1|||||||||000||||||||||H1|7606337596|Y|0000016|TEST ACCOUNT FOR TESTING|5995 AVEBURY RD|3 FL|MISSISSAUGA|ON||L5R3T8|3367876|514||||||||||001|0|CNVSYEDADE|20141211|205600||00000000|000000|||20141005|D1|7606337596

------------------------------------------------------------------------------------------------------------------------------------------------------------

Can anybody please see what mistake I'm making and how to rectify, please?

Many thanks in advance.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Dec 12, 2014 at 09:40 AM

    hii zero

    you can you data set technique for the same

    and use append data set statement.

    Regards

    Gaurav

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 12, 2014 at 09:43 AM

    Hi Cool..

    Please find the below link, to get the detals information on DATA SET technique to read file from the application server.

    http://help.sap.com/saphelp_470/helpdata/en/fc/eb3d42358411d1829f0000e829fbfe/content.htm

    Open Dataset in ABAP with Sample Program

    Regards.

    Praveer.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 12, 2014 at 09:46 AM

    here is a sample code i use in one of my program

    loop at it_header.
    concatenate it_header-rec_typ it_header-versno it_header-fvf it_header-compco it_header-clntco
    it_header-date it_header-fileno into wa_data separated by ','.
    append wa_data to it_data.
    clear wa_data.
    endloop.

    move text1 to copyfile.

    close dataset copyfile.

    open dataset copyfile for output in text mode encoding default message msg.
    loop at it_data into wa_data.
    transfer wa_data to copyfile.
    endloop.


    sort it_bsad ascending by belnr.

    loop at it_bsad.
    w_belnr = it_bsad-belnr.
    w_kunnr = it_bsad-kunnr.
    w_name1 = it_bsad-name1.
    w_shkzg = it_bsad-shkzg.
    w_bkref = it_bsad-bkref.
    w_bankn = it_bsad-bankn.
    if it_bsad-shkzg = 'H'.
    it_bsad-dmbtr = it_bsad-dmbtr * -1 .
    endif.
    w_dmbtr = w_dmbtr + it_bsad-dmbtr.
    w_checl = it_bsad-checl.
    w_cnt = w_cnt + 1.
    at end of belnr.
    it_bsad1-belnr = w_belnr.
    it_bsad1-kunnr = w_kunnr.
    it_bsad1-name1 = w_name1.
    it_bsad1-shkzg = w_shkzg.
    it_bsad1-dmbtr = w_dmbtr.
    it_bsad1-bkref = w_bkref.
    it_bsad1-bankn = w_bankn.
    it_bsad1-checl = w_checl.
    it_bsad1-cnt = w_cnt.
    append it_bsad1.
    clear it_bsad1.
    clear : w_kunnr , w_name1 , w_shkzg , w_dmbtr , w_cnt , w_bkref , w_bankn , w_checl.
    endat.
    endloop.


    loop at it_bsad1.
    it_details-rec_typ = 'D' .
    it_details-typ_det = 'CT'.
    it_details-actype = '13'.
    it_details-bc1 = ' ' .
    it_details-bc2 = ' ' .
    it_details-amount = it_bsad1-dmbtr.
    condense it_details-amount.
    if it_details-amount le 200000.
    it_details-mode = 'N' .
    else.
    it_details-mode = 'R' .
    endif.
    it_details-name1 = it_bsad1-name1.
    it_details-bc3 = ' '.
    if rd3 eq 'X'.
    it_details-sendinfo1 = it_bsad1-checl.
    it_details-sendinfo2 = it_bsad1-belnr.
    else.
    it_details-sendinfo1 = it_bsad1-checl.
    it_details-sendinfo2 = it_bsad1-belnr.
    endif.
    it_details-ifsccode = it_bsad1-bkref.
    it_details-accno = it_bsad1-bankn.
    append it_details.
    clear it_details.
    endloop.


    loop at it_details.
    concatenate it_details-rec_typ it_details-typ_det it_details-mode it_details-actype it_details-bc1
    it_details-bc2 it_details-amount it_details-name1 it_details-bc3 it_details-sendinfo1
    it_details-sendinfo2 it_details-ifsccode it_details-accno into wa_data separated by ','.
    append wa_data to it_data.
    clear wa_data.
    endloop.



    move text1 to copyfile.

    close dataset copyfile.

    open dataset copyfile for output in text mode encoding default message msg.
    loop at it_data into wa_data.
    transfer wa_data to copyfile.
    endloop.

    clear it_bsad1[].

    loop at it_bsad.
    w_kunnr = it_bsad-kunnr.
    w_name1 = it_bsad-name1.
    w_shkzg = it_bsad-shkzg.
    if it_bsad-shkzg = 'H'.
    it_bsad-dmbtr = it_bsad-dmbtr * -1 .
    endif.
    w_dmbtr = w_dmbtr + it_bsad-dmbtr.
    w_cnt = w_cnt + 1.
    at last.
    it_bsad1-kunnr = w_kunnr.
    it_bsad1-name1 = w_name1.
    it_bsad1-shkzg = w_shkzg.
    it_bsad1-dmbtr = w_dmbtr.
    it_bsad1-cnt = w_cnt.
    append it_bsad1.
    clear it_bsad1.
    clear : w_kunnr , w_name1 , w_shkzg , w_dmbtr , w_cnt.
    endat.
    endloop.



    loop at it_bsad1.
    it_trailer-rec_typ = 'T'.
    it_trailer-dbtot = '0'.
    it_trailer-debit = '0'.
    it_trailer-crtot = it_bsad1-cnt.
    it_trailer-credit = it_bsad1-dmbtr.
    condense it_trailer-credit.
    it_trailer-total = it_bsad1-cnt.
    append it_trailer.
    clear it_trailer.
    endloop.


    loop at it_trailer.
    concatenate it_trailer-rec_typ it_trailer-dbtot it_trailer-debit it_trailer-crtot it_trailer-credit it_trailer-total
    into wa_data separated by ','.
    append wa_data to it_data.
    clear wa_data.
    endloop.

    move text1 to copyfile.

    close dataset copyfile.

    open dataset copyfile for output in text mode encoding default message msg.
    loop at it_data into wa_data.
    transfer wa_data to copyfile.
    endloop.

    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.