Batch Input Program for Transaction VA01

How to Create a batch input program for transaction VA01.

The scenerio is

Input fields: Manditory fields to create a new Sales Order using VA01.

Hint: Take an existing Sales Order and use the master data which was previously used.

Conditions:
1)Upload the input data from a text file stored in your note pc.
2)Use call transaction method.
3)Your program should allow to input the file path and file name to select the data.

Here I'm attaching BDC Code for  'VA01'.

report ZBDC3_VA01
       no standard page heading line-size 255.
  include bdcrecx1.

types : begin of ty_head,
        auart(4),
        vkorg(4),
        vtweg(2),
        spart(2),
        kunnr(10),
        bstkd(10),
        end of ty_head.

types: begin of ty_item,
        matnr(18) type c,
        kwmeng(13) type c,
        end of ty_item.

data: it_head type table of ty_head.  " Header
data: wa_head like line of it_head.

data: it_item type table of ty_item.   " Item
data: wa_item like line of it_item.

data:v_kwmeng(30) type c,
     v_mabnr(30) type c.
DATA: VAL(2) TYPE N VALUE 01.
DATA : w_file2 TYPE string,
       w_file1 TYPE string.
PARAMETERS: filename LIKE rlgrap-filename.
PARAMETERS: filenam1 LIKE rlgrap-filename.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR filename.
    CALL FUNCTION 'F4_FILENAME'
    IMPORTING
      file_name = filename.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR filenam1.
    CALL FUNCTION 'F4_FILENAME'
    IMPORTING
      file_name = filenam1.

START-OF-SELECTION.

  w_file2 = filename.
  w_file1 = filenam1.
  *************** HEADER ************************
  CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
      filename                      = w_file2
     filetype                      = 'ASC'
    has_field_separator           = 'X'
    TABLES
      data_tab                      = it_head.

*************** Item *******************

  CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
      filename                      = w_file1
     filetype                      = 'ASC'
    has_field_separator           = 'X'
    TABLES
      data_tab                      = it_item.

perform open_group.
  loop at it_head into wa_head.
.
perform bdc_dynpro      using 'SAPMV45A' '0101'.
perform bdc_field       using 'BDC_CURSOR'
                              'VBAK-AUART'.
perform bdc_field       using 'BDC_OKCODE'
                              '/00'.
perform bdc_field       using 'VBAK-AUART'
                                WA_HEAD-AUART.
perform bdc_field       using 'VBAK-VKORG'
                                WA_HEAD-VKORG.
perform bdc_field       using 'VBAK-VTWEG'
                                WA_HEAD-VTWEG.
perform bdc_field       using 'VBAK-SPART'
                                WA_HEAD-SPART.
perform bdc_dynpro      using 'SAPMV45A' '4001'.
perform bdc_field       using 'BDC_OKCODE'
                              '/00'.
perform bdc_field       using 'VBKD-BSTKD'
                                WA_HEAD-BSTKD.
perform bdc_field       using 'VBKD-BSTDK'
                              '30.01.2006'.
perform bdc_field       using 'KUAGV-KUNNR'
                                WA_HEAD-KUNNR.
perform bdc_field       using 'RV45A-KETDAT'
                              '30.01.2006'.
perform bdc_field       using 'RV45A-KPRGBZ'
                              'D'.
perform bdc_field       using 'VBKD-ZTERM'
                              '0001'.
perform bdc_field       using 'VBKD-INCO1'
                              'CIF'.
perform bdc_field       using 'VBKD-INCO2'
                              'COST INSUSRABCE FRIEGHT'.

loop at it_item into wa_item .
CONCATENATE 'RV45A-MABNR(' '0' VAL ')' INTO v_MABNR. CONCATENATE 'RV45A-KWMENG(' '0' VAL ')' INTO v_kwmeng.

perform bdc_field       using 'BDC_CURSOR'
                              v_kwmeng.
perform bdc_field       using v_mabnr
                                wa_item-matnr.
perform bdc_field       using v_kwmeng
                              wa_item-kwmeng.

perform bdc_dynpro      using 'SAPMV45A' '4001'.
perform bdc_field       using 'BDC_OKCODE'
                              '/00'.

VAL = VAL + 1.
IF VAL >   5.
   VAL = 5.
ENDIF.
  endloop.
VAL = 01.

perform bdc_dynpro   using 'SAPMV45A' '4001'.
perform bdc_field       using 'BDC_OKCODE'
                              '=SICH'.
perform bdc_transaction using 'VA01'.
endloop.
perform close_group.

*-- Reddy

Related:

ABAP Books List
ABAP/4 Certification, Programming, Smartforms, Sapscripts and Object Oriented Programming Books

ABAP Menu:
ABAP Example Hints and Tips

Return to Index:-
SAP ABAP/4 Programming, Basis Administration, Configuration Hints and Tips

(c) www.gotothings.com All material on this site is Copyright.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
All product names are trademarks of their respective companies.  The site www.gotothings.com is in no way affiliated with SAP AG.
Any unauthorised copying or mirroring is prohibited.