Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Multiple file creation

Former Member
0 Likes
753

Hi.

I have to create multiple files for mulitiple plants entered through select-options.

I have done this for single file but not getting the idea how to do it for multiple files.

<u><b><b>My work:</b></b></u>

*File creation

CONCATENATE

c_path "file path

c_qm " 'QM'

c_underscore "underscore

c_results " 'RESULTS'

c_underscore

s_werks "plant

c_underscore

sy-datum+4(2) "system date

sy-datum+6(2)

sy-datum+0(4)

c_underscore

sy-uzeit+0(2) "system time

sy-uzeit+2(2)

c_ext "file extension

INTO g_file_name.

ENDLOOP.

  • Open File on the application server for processing

OPEN DATASET g_file_name FOR OUTPUT IN TEXT MODE

ENCODING DEFAULT.

IF sy-subrc NE 0.

*Display error message

MESSAGE i055. " Error in opening file

LEAVE LIST-PROCESSING.

ELSE.

LOOP AT i_final INTO wa_final.

TRANSFER wa_final TO g_file_name.

ENDLOOP.

ENDIF.

CLOSE DATASET g_file_name.

  • Then i am updating the database table using i_update

  • Work Area for Z_DATADOWNLOAD table

DATA: l_wa_update TYPE ztable

l_wa_update-prog_name = g_repid.

l_wa_update-plant = s_werks.

l_wa_update-last_run_dt = g_sysdate.

l_wa_update-last_run_tm = g_systime.

MODIFY ztable FROM l_wa_update.

Pls let me know how to manage this for multiple files.

1 ACCEPTED SOLUTION
Read only

Manohar2u
Active Contributor
0 Likes
692

You might have the following flow logic in your program

Extract the data based on given plant.

Moving data into i_final table.

Now you change as below.

loop at itab.

where itab is the list of selected plants from SELECT statement.

Extract the data

write into application server.

endloop.

Regds

Manohar

Pls reward if helpful.

4 REPLIES 4
Read only

Manohar2u
Active Contributor
0 Likes
693

You might have the following flow logic in your program

Extract the data based on given plant.

Moving data into i_final table.

Now you change as below.

loop at itab.

where itab is the list of selected plants from SELECT statement.

Extract the data

write into application server.

endloop.

Regds

Manohar

Pls reward if helpful.

Read only

Former Member
0 Likes
692

Hi.

I have already extracted the data into the final internal table i_final.

However,

my plant selections are on table i_t001w

so i am looping it with i_t001w > creating file name> writing it into app server(using table i_final)--> updating the database table (using i_update).

Can it be possible?

Rgds,

Simran

Read only

Manohar2u
Active Contributor
0 Likes
692

Yes this is the way you should approach for writing a file per plant.

Regds

Manohar

Read only

Former Member
0 Likes
692

Hi Simran.

Consider this code.


REPORT zztest.
TABLES : t001w.

*Declare one Internal table for werks
DATA :BEGIN OF it_werks OCCURS 0,
      werks TYPE t001w-werks,
      END OF it_werks.

*Select options
SELECT-OPTIONS : s_werks FOR t001w-werks.

START-OF-SELECTION.


*GEt all the plants entered in selection screen from
*DB table <b>T001W (Plants/Branches)</b>

  SELECT werks FROM t001w INTO TABLE it_werks WHERE werks IN s_werks.

*Loop that internal table
<b>  LOOP AT it_werks.</b>
    CONCATENATE
    c_path "file path
    c_qm " 'QM'
    c_underscore   "underscore
    c_results      " 'RESULTS'
    c_underscore
   <b> it_werks-werks    "Plant</b>
    c_underscore
    sy-datum+4(2)    "system date
    sy-datum+6(2)
    sy-datum+0(4)
    c_underscore
    sy-uzeit+0(2)  "system time
    sy-uzeit+2(2)
    c_ext "file extension

    INTO g_file_name.

<b>*Now you have the file path for the werks
*Open File on the application server for processing</b>


    OPEN DATASET g_file_name FOR OUTPUT IN TEXT MODE
    ENCODING DEFAULT.

    IF sy-subrc NE 0.

*Display error message
      MESSAGE i055. " Error in opening file
      LEAVE LIST-PROCESSING.

    ELSE.

      LOOP AT i_final INTO wa_final.

        TRANSFER wa_final TO g_file_name.

      ENDLOOP.
    ENDIF.
    CLOSE DATASET g_file_name.

* Then i am updating the database table using i_update
* Work Area for Z_DATADOWNLOAD table

    DATA: l_wa_update TYPE ztable


    l_wa_update-prog_name = g_repid.
    l_wa_update-plant = s_werks.
    l_wa_update-last_run_dt = g_sysdate.
    l_wa_update-last_run_tm = g_systime.

    MODIFY ztable FROM l_wa_update.

*Pls let me know how to manage this for multiple files.

<b>  ENDLOOP.</b>

Regards,

Arun Sambargi.