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

BATCH INPUT

Former Member
0 Likes
716

Hi!!

How can i call a batch input in a report??

5 REPLIES 5
Read only

Former Member
0 Likes
670

Use CALL TRANSACTION.

Rob

Read only

0 Likes
670

A simple call transaction report using batch input may look simular to this. You can record the transaction using transaction SHDB, then copy the code to your program(just the PERFORM statements), then you can simply call the transaction using BDCDATA.

In this case, this program updates new standard prices for materials from a file on the PC which has material, plant and the new standard price, it uses transaction MR21 to update the system.



report zrich_0002
       no standard page heading
       line-size 132.

data: iflat type table of string with header line.

data: begin of itab occurs 0,
      matnr type marc-matnr,
      werks type marc-werks,
      stdpr(10) type c,
      end of itab.

data: pdate(10) type c.

data: bdcdata like bdcdata occurs 20 with header line,
      mode(1) type c value 'N'.

selection-screen skip 1.
parameters: p_file type localfile default
            'C:Std_Price.txt'.
parameters: p_date like sy-datum.
selection-screen skip 1.

at selection-screen on value-request for p_file.
  call function 'KD_GET_FILENAME_ON_F4'
       exporting
            static    = 'X'
       changing
            file_name = p_file.


start-of-selection.

  perform upload_data.
  perform process_records.


************************************************************************
* Upload_Data
************************************************************************
form upload_data.


  clear iflat. refresh iflat.
  clear itab. refresh itab.


  call function 'GUI_UPLOAD'
       exporting
            filename = p_file
       tables
            data_tab = iflat.


  loop at iflat.
    split iflat at ',' into itab-matnr itab-werks itab-stdpr.

    call function 'CONVERSION_EXIT_MATN1_INPUT'
         exporting
              input  = itab-matnr
         importing
              output = itab-matnr.
    append itab.
  endloop.

endform.

************************************************************************
* Process_Records
************************************************************************
form process_records.


  concatenate p_date+4(2) '/' p_date+6(2) '/' p_date(4)
          into pdate.

  loop at itab.

<b>
    perform bdc_dynpro      using 'SAPRCKM_MR21' '0201'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'MR21HEAD-WERKS'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=ENTR'.
    perform bdc_field       using 'MR21HEAD-BUDAT'
                                pdate.
    perform bdc_field       using 'MR21HEAD-BUKRS'
                                  '0010'.
    perform bdc_field       using 'MR21HEAD-WERKS'
                                itab-werks.
    perform bdc_field       using 'MR21HEAD-SCREEN_VARIANT'
                                  'MR21_LAGERMATERIAL_0250'.
    perform bdc_dynpro      using 'SAPRCKM_MR21' '0201'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=ENTR'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'CKI_MR21_0250-NEWVALPR(01)'.
    perform bdc_field       using 'MR21HEAD-SCREEN_VARIANT'
                                  'MR21_LAGERMATERIAL_BWKEY_0250'.
    perform bdc_field       using 'CKI_MR21_0250-MATNR(01)'
                                itab-matnr.
    perform bdc_field       using 'CKI_MR21_0250-NEWVALPR(01)'
                                itab-stdpr.
    perform bdc_dynpro      using 'SAPRCKM_MR21' '0201'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=SAVE'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'CKI_MR21_0250-MATNR(02)'.
    perform bdc_field       using 'MR21HEAD-SCREEN_VARIANT'
                                  'MR21_LAGERMATERIAL_BWKEY_0250'.

    call transaction 'MR21' using bdcdata mode mode
            update 'S'.</b>

    if sy-subrc = 0.
      write:/ 'S', itab-matnr, itab-werks,
      'updated successfully'.
    else.
      write:/ 'E', itab-matnr, itab-werks,
               'error trying to update'.
    endif.

    clear bdcdata.   refresh bdcdata.

  endloop.

endform.
<b>
************************************************************************
*      Form  BDC_DYNPRO
************************************************************************

form bdc_dynpro using  program dynpro.

  clear bdcdata.
  bdcdata-program = program.
  bdcdata-dynpro = dynpro.
  bdcdata-dynbegin = 'X'.
  append bdcdata.

endform.

************************************************************************
*      Form  BDC_FIELD
************************************************************************

form bdc_field using fnam fval.

  clear bdcdata.
  bdcdata-fnam = fnam.
  bdcdata-fval = fval.
  append bdcdata.

endform.</b>

Regards,

Rich Heilman

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
670
Read only

Former Member
0 Likes
670

Just incase you are reffering to type BINP, below info might be helpful.

1. Each BINP refers to a program.

2. We can use SUBMIT statement for calling the program with the dataset name i.e path and file with data for uploading.

3. Each BINP Program has multi structures and can identified by record types.

4. For more on this you can refer to transactions: SXDA, SXDB and use menupath Goto->DX Tools.

Kind Regards

Eswar

Read only

Former Member
0 Likes
670

Hello ,

I am going into the process of BATCH INPUT .And I need to load up students's table where his data come from a file excel and no himself like to program it

Thanks FOR HELP