Bdc va01

hi Data transfer gurus,
                                  i m writing a bdc program for updating sales data (vao1)
                                   frnds can anyone provide to logic  for how to update                                                                     the tax
                                       for a paticular material .
       If anyone having code they can mail me at [email protected]
        thnking u all.
                                                                      regards,
                                                                        sanjay

Hi Abir,
            This is the code can u just correct me.
report ZTESTVA1 no standard page heading.
TABLES: KUAGV,
        VBKD,
        VBAK,
        VBAP,
        KONV,
        RV61A.
DATA: BEGIN OF ITAB OCCURS 0,
     AUART LIKE VBAK-AUART,
     VKORG LIKE VBAK-VKORG,
     VTWEG LIKE VBAK-VTWEG,
     SPART LIKE VBAK-SPART,
     KUNNR LIKE KUAGV-KUNNR,
     FKDAT(10) TYPE C,
     AUGRU LIKE VBAK-AUGRU,
     MATNR LIKE VBAP-MATNR,
     ZMENG LIKE VBAP-ZMENG,
     KSCHL LIKE KOMV-KSCHL,
     KBETR LIKE KOMV-KBETR,
    END OF ITAB.
DATA: BEGIN OF ITAB_ITEM OCCURS 0,
      MATNR LIKE VBAP-MATNR,
      ZMENG LIKE VBAP-ZMENG,
      KSCHL LIKE KOMV-KSCHL,
      KBETR LIKE KOMV-KBETR,
      END OF ITAB_ITEM.
DATA: BEGIN OF ITAB_FILE OCCURS 0,
      END OF ITAB_FILE.
DATA: WRITE ITAB_KBETR TO IT_KBETR.
include bdcrecxx.
SELECTION-SCREEN BEGIN OF BLOCK B2  WITH FRAME TITLE TEXT-002.
SELECTION-SCREEN BEGIN OF BLOCK B2A WITH FRAME TITLE TEXT-003.
PARAMETER: CB_PC AS CHECKBOX.
PARAMETER: P_PCFILE LIKE RLGRAP-FILENAME DEFAULT 'c:\temp\sorders.txt'.
SELECTION-SCREEN END OF BLOCK B2A.
SELECTION-SCREEN BEGIN OF BLOCK B2B WITH FRAME TITLE TEXT-004.
PARAMETER: CB_UX AS CHECKBOX.
PARAMETER: P_UFILE LIKE RLGRAP-FILENAME DEFAULT '/hqspool/sorders.txt'.
SELECTION-SCREEN END OF BLOCK B2B.
SELECTION-SCREEN END OF BLOCK B2.
AT SELECTION-SCREEN.
    IF CB_PC IS INITIAL AND CB_UX IS INITIAL.
      MESSAGE E000(ZZ) WITH 'Choose one of the download Options.'.
    ENDIF.
    IF CB_PC = 'X' AND P_PCFILE IS INITIAL.
      MESSAGE S000(ZZ) WITH 'Provide a PC filename.'.
    ENDIF.
START-OF-SELECTION.
*TO UPLOAD DATA FROM THE PRESENTATION SERVER.
IF CB_PC = 'X'.
CALL FUNCTION 'WS_UPLOAD'
    EXPORTING
         FILENAME             = P_PCFILE
         FILETYPE             = 'DAT'
     TABLES
          DATA_TAB            = ITAB
     EXCEPTIONS
          CONVERSION_ERROR    = 1
          FILE_OPEN_ERROR     = 2
          FILE_READ_ERROR     = 3
          INVALID_TABLE_WIDTH = 4
          INVALID_TYPE        = 5
          NO_BATCH            = 6
          UNKNOWN_ERROR       = 7
          OTHERS              = 8.
IF SY-SUBRC = 0.
      MESSAGE S000(ZZ) WITH P_PCFILE ' uploaded successfully.'.
    ENDIF.
ENDIF.
TO UPLOAD THE FILE FROM THE APPLICATION SERVER.
IF CB_UX = 'X'.
   OPEN DATASET P_UFILE FOR INPUT IN TEXT MODE.
   IF SY-SUBRC NE 0.
    MESSAGE E000(ZZ) WITH 'Unable to open the Unix File.'.
   ENDIF.
   DO.
    READ DATASET P_UFILE INTO ITAB.
     IF SY-SUBRC <> 0.
      EXIT.
     ENDIF.
     APPEND ITAB.
   ENDDO.
   CLOSE DATASET P_UFILE.
   ENDIF.
perform open_group.
LOOP AT ITAB.
REFRESH ITAB.
perform bdc_dynpro      using 'SAPMV45A' '0101'.
perform bdc_field       using 'BDC_OKCODE'
                              'ENT2'.
perform bdc_field       using 'BDC_CURSOR'
                              'VBAK-SPART'.
perform bdc_field       using 'VBAK-AUART'
                               ITAB-AUART.
perform bdc_field       using 'VBAK-VKORG'
                               ITAB-VKORG.
perform bdc_field       using 'VBAK-VTWEG'
                               ITAB-VTWEG.
perform bdc_field       using 'VBAK-SPART'
                               ITAB-SPART.
perform bdc_dynpro      using 'SAPMV45A' '0415'.
perform bdc_field       using 'BDC_OKCODE'
                              'ENT1'.
perform bdc_field       using 'BDC_CURSOR'
                              'VBAK-AUGRU'.
perform bdc_field       using 'KUAGV-KUNNR'
                               ITAB-KUNNR.
perform bdc_field       using 'VBKD-FKDAT'
                               ITAB-FKDAT.
perform bdc_field       using 'VBAK-AUGRU'
                               ITAB-AUGRU.
perform bdc_field       using 'VBAP-MATNR(01)'
perform bdc_field       using 'VBAP-ZMENG(01)'
LOOP AT ITAB_ITEM.
REFRESH ITAB_ITEM.
perform bdc_dynpro      using 'SAPMV45A' '0415'.
perform bdc_field       using 'BDC_OKCODE'
                              'POAN'.
perform bdc_field       using 'BDC_CURSOR'
                              'VBAP-MATNR(01)'.
perform bdc_dynpro      using 'SAPMV45A' '0415'.
perform bdc_field       using 'BDC_OKCODE'
                              'ENT1'.
perform bdc_field       using 'BDC_CURSOR'
                              'VBAP-ZMENG(01)'.
perform bdc_field       using 'VBAP-MATNR(01)'
                               ITAB-MATNR.
perform bdc_field       using 'VBAP-ZMENG(01)'
                               ITAB-ZMENG.
perform bdc_dynpro      using 'SAPMV45A' '0415'.
perform bdc_field       using 'BDC_OKCODE'
                              'POPO'.
perform bdc_field       using 'BDC_CURSOR'
                              'VBAP-MATNR(01)'.
perform bdc_dynpro      using 'SAPMV45A' '0251'.
perform bdc_field       using 'BDC_OKCODE'
                              'POSI'.
perform bdc_field       using 'BDC_CURSOR'
                              'RV45A-POSNR'.
perform bdc_field       using 'RV45A-POSNR'
                              '10'.
perform bdc_dynpro      using 'SAPMV45A' '0415'.
perform bdc_field       using 'BDC_OKCODE'
                              'PKON'.
perform bdc_field       using 'BDC_CURSOR'
                              'VBAP-MATNR(01)'.
perform bdc_dynpro      using 'SAPMV61A' '0620'.
perform bdc_field       using 'BDC_OKCODE'
                              'ENT1'.
perform bdc_field       using 'BDC_CURSOR'
                              'KOMV-KBETR(4)'.
perform bdc_field       using 'KOMV-KSCHL(4)'
                               ITAB-KSCHL.
perform bdc_field       using 'KOMV-KBETR(4)'
                               ITAB-KBETR.
perform bdc_dynpro      using 'SAPMV61A' '0620'.
perform bdc_field       using 'BDC_OKCODE'
                              'ENT1'.
perform bdc_field       using 'BDC_CURSOR'
                              'KOMV-KBETR(5)'.
perform bdc_field       using 'KOMV-KSCHL(5)'
                               ITAB-KSCHL.
perform bdc_field       using 'KOMV-KBETR(5)'
                               IT-KBETR.
perform bdc_dynpro      using 'SAPMV61A' '0620'.
perform bdc_field       using 'BDC_OKCODE'
                              'ENT1'.
perform bdc_field       using 'BDC_CURSOR'
                              'KOMV-KBETR(6)'.
perform bdc_field       using 'KOMV-KSCHL(6)'
                               ITAB-KSCHL.
perform bdc_field       using 'KOMV-KBETR(6)'
                               ITAB-KBETR.
perform bdc_dynpro      using 'SAPMV61A' '0620'.
perform bdc_field       using 'BDC_OKCODE'
                              'ENT1'.
perform bdc_field       using 'BDC_CURSOR'
                              'KOMV-KBETR(7)'.
perform bdc_field       using 'KOMV-KSCHL(7)'
                               ITAB-KSCHL.
perform bdc_field       using 'KOMV-KBETR(7)'
                               IT-KBETR.
ENDLOOP.
perform bdc_dynpro      using 'SAPMV61A' '0620'.
perform bdc_field       using 'BDC_OKCODE'
                              'BACK'.
perform bdc_field       using 'BDC_CURSOR'
                              'KOMV-KBETR(01)'.
perform bdc_dynpro      using 'SAPMV45A' '0415'.
perform bdc_field       using 'BDC_OKCODE'
                              'SICH'.
perform bdc_field       using 'BDC_CURSOR'
                              'VBAK-FAKSK'.
perform bdc_field       using 'VBAK-FAKSK'
perform bdc_transaction using 'VA01'.
refresh bdcdata.
perform bdc_dynpro      using 'SAPMV45A' '0102'.
perform bdc_field       using 'BDC_OKCODE'
                              'ENT2'.
perform bdc_field       using 'BDC_CURSOR'
                              'VBAK-VBELN'.
perform bdc_dynpro      using 'SAPMV45A' '0415'.
perform bdc_field       using 'BDC_OKCODE'
                              'SICH'.
perform bdc_field       using 'BDC_CURSOR'
                              'VBAK-FAKSK'.
perform bdc_field       using 'VBAK-FAKSK'
perform bdc_transaction using 'VA02'.
perform close_group.
ENDLOOP.
help me regarding this.
regards,
sanjay
<b> NOTE : IF U HAV ANY DEFULT CODE PLZ SEND TO [email protected]</B>

Similar Messages

  • BDC VA01 in background mode error

    Hi ,
    I am psoting data into VA01 using BDC call transaction in background mode for two cases.
    For one it is running successfully and for the other it is not.
    I have compared the data in the table BDCDATA for both the cases and it is same.
    Then I tried debugging in foreground mode and the same case which was not running earlier is running in foreground mode.
    Please advice what could be the problem?

    >
    ABHI wrote:
    > I am getting the following messages:
    >
    >
    >
    > TCODE     DYNAME     DYNUMB     MSGTYP     MSGID     MSGNR     MSGV1     MSGV2     MSGV3     ENV
    > VA01     SAPMV45A     4001     W     VU     1          Purchase order date          CTU
    > VA01     SAPMV45A     4001     W     V1     221     5/27/2010               CTU
    > VA01     SAPMV45A     103     I     V1     81                    CD
    > VA01     SAPMSSY3     131     S     0     344     SAPMSSY3     131          CTU
    Hello ABHI,
    The problem is because of some breakpoints created by you. So it is entering it to debugger in the background mode which cannot be handled by the BDC. Delete all your breakpoints before testing or open a new logon session to test it in background.
    Hope this solves your problem.
    Regards,
    Karthik D

  • How to create a Sales order with ref to Contract using Function Module

    How to create a Sales order with ref to Contract using Function Module BAPI_SALESDOCU_CREATEFROMDATA ?

    We have a unique situation where we like change the sold-to customer of the sales order
    once order has been created. These orders have been created using either by function module
    BAPI_SALESDOCUMENT_COPY or using BDC (VA01, Copy with reference).
    These two processes work abosolutely fine except someone might have change the sold-to
    customer of the ship-to customer of the original sales order. If this the case then the new
    sales order will be created with the old sold-to and with not the new sold-to.
    We tried using BAPI_SALESDOCUMENT_CHANGE and commit afterwards. We checked
    the returned parameteres of the BAPIs and they are all successful but sold-to remains the
    same old one.
    Any help would be much more appreciated.

  • Detection of Updating mode

    Hello everybody,
    We can upload Sales order using BDC, LSMW, BAPI or IDOC. Once the document no gets generated can we say by which method the document got generated ie by  using BDC, VA01, LSMW, BAPI or idoc. If yes, I want to know how. Suppose there is one sales order which got created six months back, can we tell how was it created.
    Regards
    Debopriyo Mallick

    J.K.
    Turn out that member listener approach still have chance to lost update notification.
    We found out that the update occurred between MemberLeft event notification and re-add map listener will be lost.
    That window is small, however, our business requirement require that no lost of update event at all as long as the update operation succeeded (the update could be performed by another extend client connect to different proxy node).
    Is it even possible to ensure that requirement using extend client?
    Regards,
    Chen

  • Sales order: How to add pricing conditions at item level in BDC of VA01

    Hello Experts,
    Am writing BDC for sales order, in this process I need to add ITEM PRICING CONDITIONS, so, am selecting item and pressing the DOLLAR symbol button and am adding the conditions by pressing PLUS button in loop!! but am getting this erorr- Field KOMV-KMEIN (2) is not an input field!! when I execute it in we19-BACK GROUND only!! if I execute the same CODE IN we19-Fore ground, I dont have any issue!!  I checked this SDN (field status in config), Google, but did not helped me!
    Pls. let  me know is there any other way to add conditions at item level in VA01 in BDC code?
    THank you

    Hi,
    It is happening because the second row of the item level data screen is becoming display only. Please check whether In foreground mode you are pressing an extra enter to give data in the second row of the item level data after giving data in the first row and in BDC recording you have not recorded that 'Enter'.
    Regards,
    Gargi

  • Is BDC's CALL TRANSACTION 'VA01' is not equals to ONLINE(manual) creation?

    Hi Experts,
    Ours is IS-Oil.
    If the user do not enters/inputs OIC_MOT (Mode Of Transport) at ITEM level on the External Details popup, SAP will get it from Customar Master-KNA1 and populates on it, because its a mandatory field (OIC_MOT), but, do not throws an Error message and interupts the sales order creation process.
    We have a inbound IDOC posting function module for sales order (VA01), which posts the sales oreders by using BDC (CALL TRANSACTION 'VA01') in the system. In this function module, we are not populating the OIC_MOT field contained segment by hoping SAP will populate/default it while it hits CALL TRANSACTION 'VA01' of my BDC of my FM of IB IDOC. But, SAP is not defaulting/populating and throwing error message (saying 'OIC_MOT field is a mandatory input field' data is missing) and IDOC is failing, pls. let me know Wht its so? is the BDC's CALL TRANSACTION 'VA01' is not equals to ONLINE (manual ) creation of sales order?
    Thank you

    Hi
    Several transactions can ba a different behavior between online and bdc process, but if you simulate the trx by SM35 you should find out these gaps
    I don't know OIL vertical, but the main transactions have a bapi can be used insted of BDC program (BAPI_SALESORDER_CREATEFROMDAT2, but perhaps there's a particular BAPI for OIL).
    Max

  • Problem in BDC for VA01 transaction TEXTS tab(Upgrading from 4.5b to ECC6)

    Hi All,
    I am working in upgrade project from 4.5b version to ECC6 version.
    I am facing problem in TEXTS tab of VA01 transaction. In earlier version it is a table control containing of Language, Description & First line but, in ECC6 the screen is modified with texteditor, a list box for language key and a Text type at the left.
    Now my problem is how to record this in BDC and how to read the text in the texteditor?
    Thanks in Advance,
    Ravi Kiran.

    Hi Seshagiri,
    In this case i would suggest the use of BAPI if there's no compulsion to use BDC.
    BAPI_SALESORDER_CHANGE                     Sales order: Change Sales Order
    BAPI_SALESORDER_CONFIRMDELVRY
    BAPI_SALESORDER_CREATEFROMDAT1    Sales order: Create Sales Order
    BAPI_SALESORDER_CREATEFROMDAT2    Sales order: Create Sales Order
    BAPI_SALESORDER_CREATEFROMDATA    Create Sales Order, No More
    BAPI_SALESORDER_GETLIST        Sales order: List of all Orders for Customer
    BAPI_SALESORDER_GETSTATUS      Sales Order: Display Status
    BAPI_SALESORDER_SIMULATE       Sales Order: Simulate Sales Order
    try using these for creation or change of orders instead of bdcs.
    hope this helps and revert for more clarifications if any.
    <b>Always reward points to useful suggestions.</b>
    regards,
    Vikas

  • BDC to create SO(VA01) for multiple line items

    Hi all,
    My requirement is to create SO for multiple line items in ECC6.0
    My recording for VA01 is like this.
    start-of-selection.
    perform open_group.
    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'
                                  'ZOR'.
    perform bdc_field       using 'VBAK-VKORG'
                                  '2000'.
    perform bdc_field       using 'VBAK-VTWEG'
                                  '10'.
    perform bdc_field       using 'VBAK-SPART'
                                  '05'.
    perform bdc_dynpro      using 'SAPMV45A' '4001'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'VBKD-BSTKD'
                                  'open SO'.
    perform bdc_field       using 'VBKD-BSTDK'
                                  '29.01.2008'.
    perform bdc_field       using 'KUAGV-KUNNR'
                                  '100000'.
    perform bdc_field       using 'KUWEV-KUNNR'
                                  '100000'.
    perform bdc_field       using 'RV45A-KETDAT'
                                  '29.01.2008'.
    perform bdc_field       using 'RV45A-KPRGBZ'
                                  'D'.
    perform bdc_field       using 'VBKD-PRSDT'
                                  '29.01.2008'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'VBAP-WERKS(01)'.
    perform bdc_field       using 'RV45A-MABNR(01)'
                                  'hrpocf'.
    perform bdc_field       using 'VBAP-POSNR(01)'
                                  '    10'.
    perform bdc_field       using 'RV45A-KWMENG(01)'
                                  '                 55'.
    perform bdc_field       using 'VBAP-WERKS(01)'
                                  '2010'.
    perform bdc_dynpro      using 'SAPLCEI0' '0109'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'RCTMS-MWERT(06)'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=BACK'.
    perform bdc_field       using 'RCTMS-MNAME(01)'
                                  'A_THICK_MM'.
    perform bdc_field       using 'RCTMS-MNAME(02)'
                                  'A_WIDTH_MM'.
    perform bdc_field       using 'RCTMS-MNAME(03)'
                                  'A_EQUIVALENT_SPEC'.
    perform bdc_field       using 'RCTMS-MNAME(04)'
                                  'A_BATCH_WEIGHT_MAX_SI'.
    perform bdc_field       using 'RCTMS-MNAME(05)'
                                  'A_BATCH_WEIGHT_MIN_SI'.
    perform bdc_field       using 'RCTMS-MNAME(06)'
                                  'A_COIL_INNER_DIA_MM'.
    perform bdc_field       using 'RCTMS-MWERT(01)'
                                  '3.2'.
    perform bdc_field       using 'RCTMS-MWERT(02)'
                                  '1200'.
    perform bdc_field       using 'RCTMS-MWERT(03)'
                                  'IS_11513_GR_D_1985'.
    perform bdc_field       using 'RCTMS-MWERT(04)'
                                  '26.4'.
    perform bdc_field       using 'RCTMS-MWERT(05)'
                                  '26.4'.
    perform bdc_field       using 'RCTMS-MWERT(06)'
                                  '610'.
    perform bdc_dynpro      using 'SAPMV45A' '4001'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'VBKD-BSTKD'
                                  'open SO'.
    perform bdc_field       using 'VBKD-BSTDK'
                                  '29.01.2008'.
    perform bdc_field       using 'KUAGV-KUNNR'
                                  '100000'.
    perform bdc_field       using 'KUWEV-KUNNR'
                                  '100000'.
    perform bdc_field       using 'RV45A-KETDAT'
                                  '29.01.2008'.
    perform bdc_field       using 'RV45A-KPRGBZ'
                                  'D'.
    perform bdc_field       using 'VBKD-PRSDT'
                                  '29.01.2008'.
    perform bdc_field       using 'VBKD-INCO1'
                                  'EXW'.
    perform bdc_field       using 'VBKD-INCO2'
                                  'mumbai east'.
    perform bdc_field       using 'VBKD-ZTERM'
                                  '0001'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'VBAP-WERKS(02)'.
    perform bdc_field       using 'RV45A-MABNR(02)'
                                  'hrpocf'.
    perform bdc_field       using 'VBAP-POSNR(02)'
                                  '    11'.
    perform bdc_field       using 'RV45A-KWMENG(02)'
                                  '                 66'.
    perform bdc_field       using 'VBAP-WERKS(02)'
                                  '2010'.
    perform bdc_dynpro      using 'SAPLCEI0' '0109'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'RCTMS-MWERT(06)'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=BACK'.
    perform bdc_field       using 'RCTMS-MNAME(01)'
                                  'A_THICK_MM'.
    perform bdc_field       using 'RCTMS-MNAME(02)'
                                  'A_WIDTH_MM'.
    perform bdc_field       using 'RCTMS-MNAME(03)'
                                  'A_EQUIVALENT_SPEC'.
    perform bdc_field       using 'RCTMS-MNAME(04)'
                                  'A_BATCH_WEIGHT_MAX_SI'.
    perform bdc_field       using 'RCTMS-MNAME(05)'
                                  'A_BATCH_WEIGHT_MIN_SI'.
    perform bdc_field       using 'RCTMS-MNAME(06)'
                                  'A_COIL_INNER_DIA_MM'.
    perform bdc_field       using 'RCTMS-MWERT(01)'
                                  '3.1'.
    perform bdc_field       using 'RCTMS-MWERT(02)'
                                  '1250'.
    perform bdc_field       using 'RCTMS-MWERT(03)'
                                  'IS_11513_GR_D_1985'.
    perform bdc_field       using 'RCTMS-MWERT(04)'
                                  '20.084'.
    perform bdc_field       using 'RCTMS-MWERT(05)'
                                  '20.084'.
    perform bdc_field       using 'RCTMS-MWERT(06)'
                                  '610'.
    perform bdc_dynpro      using 'SAPMV45A' '4001'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=PDE3'.
    perform bdc_field       using 'VBKD-BSTKD'
                                  'open SO'.
    perform bdc_field       using 'VBKD-BSTDK'
                                  '29.01.2008'.
    perform bdc_field       using 'KUAGV-KUNNR'
                                  '100000'.
    perform bdc_field       using 'KUWEV-KUNNR'
                                  '100000'.
    perform bdc_field       using 'RV45A-KETDAT'
                                  '29.01.2008'.
    perform bdc_field       using 'RV45A-KPRGBZ'
                                  'D'.
    perform bdc_field       using 'VBKD-PRSDT'
                                  '29.01.2008'.
    perform bdc_field       using 'VBKD-INCO1'
                                  'EXW'.
    perform bdc_field       using 'VBKD-INCO2'
                                  'mumbai east'.
    perform bdc_field       using 'VBKD-ZTERM'
                                  '0001'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'VBAP-POSNR(01)'.
    perform bdc_field       using 'RV45A-VBAP_SELKZ(01)'
                                  'X'.
    perform bdc_dynpro      using 'SAPMV45A' '4003'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=T\09'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'VBKD-INCO2'.
    perform bdc_field       using 'VBKD-INCO1'
                                  'EXW'.
    perform bdc_field       using 'VBKD-INCO2'
                                  'mumbai'.
    perform bdc_field       using 'VBKD-ZTERM'
                                  '0001'.
    perform bdc_field       using 'VBKD-FKDAT'
                                  '29.01.2008'.
    perform bdc_field       using 'VBAP-TAXM1'
                                  '1'.
    perform bdc_field       using 'VBAP-TAXM2'
                                  '1'.
    perform bdc_field       using 'VBAP-TAXM3'
                                  '0'.
    perform bdc_field       using 'VBAP-TAXM4'
                                  '0'.
    perform bdc_dynpro      using 'SAPMV45A' '4003'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=TP_DELETE'.
    perform bdc_field       using 'LV70T-SPRAS'
                                  'EN'.
    perform bdc_dynpro      using 'SAPMV45A' '4003'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=TP_CREATE'.
    perform bdc_field       using 'LV70T-SPRAS'
                                  'EN'.
    perform bdc_dynpro      using 'SAPMV45A' '4003'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=TP_DETAIL'.
    perform bdc_field       using 'LV70T-SPRAS'
                                  'EN'.
    perform bdc_dynpro      using 'SAPLSTXX' '1100'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'RSTXT-TXLINE(02)'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=TXVB'.
    perform bdc_field       using 'RSTXT-TXLINE(02)'
                                  'FDGFDG'.
    perform bdc_dynpro      using 'SAPLSTXX' '1100'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'RSTXT-TXLINE(02)'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=TXBA'.
    perform bdc_dynpro      using 'SAPMV45A' '4003'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=T\10'.
    perform bdc_dynpro      using 'SAPMV45A' '4003'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/EBACK'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'VBKD-POSEX_E'.
    perform bdc_field       using 'VBKD-BSTKD'
                                  'open SO'.
    perform bdc_field       using 'VBKD-BSTDK'
                                  '29.01.2008'.
    perform bdc_field       using 'VBAP-POSEX'
                                  '108128'.
    perform bdc_field       using 'VBKD-BSTKD_E'
                                  '3011192'.
    perform bdc_field       using 'VBKD-POSEX_E'
                                  '000005'.
    perform bdc_dynpro      using 'SAPMV45A' '4001'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=PDE3'.
    perform bdc_field       using 'VBKD-BSTKD'
                                  'open SO'.
    perform bdc_field       using 'VBKD-BSTDK'
                                  '29.01.2008'.
    perform bdc_field       using 'KUAGV-KUNNR'
                                  '100000'.
    perform bdc_field       using 'KUWEV-KUNNR'
                                  '100000'.
    perform bdc_field       using 'RV45A-KETDAT'
                                  '29.01.2008'.
    perform bdc_field       using 'RV45A-KPRGBZ'
                                  'D'.
    perform bdc_field       using 'VBKD-PRSDT'
                                  '29.01.2008'.
    perform bdc_field       using 'VBKD-INCO1'
                                  'EXW'.
    perform bdc_field       using 'VBKD-INCO2'
                                  'mumbai east'.
    perform bdc_field       using 'VBKD-ZTERM'
                                  '0001'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'VBAP-POSNR(02)'.
    perform bdc_field       using 'RV45A-VBAP_SELKZ(02)'
                                  'X'.
    perform bdc_dynpro      using 'SAPMV45A' '4003'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=T\09'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'VBKD-INCO2'.
    perform bdc_field       using 'VBKD-INCO1'
                                  'EXW'.
    perform bdc_field       using 'VBKD-INCO2'
                                  'mumbai'.
    perform bdc_field       using 'VBKD-ZTERM'
                                  '0001'.
    perform bdc_field       using 'VBKD-FKDAT'
                                  '29.01.2008'.
    perform bdc_field       using 'VBAP-TAXM1'
                                  '1'.
    perform bdc_field       using 'VBAP-TAXM2'
                                  '1'.
    perform bdc_field       using 'VBAP-TAXM3'
                                  '0'.
    perform bdc_field       using 'VBAP-TAXM4'
                                  '0'.
    perform bdc_dynpro      using 'SAPMV45A' '4003'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=TP_DELETE'.
    perform bdc_field       using 'LV70T-SPRAS'
                                  'EN'.
    perform bdc_dynpro      using 'SAPMV45A' '4003'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=TP_CREATE'.
    perform bdc_field       using 'LV70T-SPRAS'
                                  'EN'.
    perform bdc_dynpro      using 'SAPMV45A' '4003'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=TP_DETAIL'.
    perform bdc_field       using 'LV70T-SPRAS'
                                  'EN'.
    perform bdc_dynpro      using 'SAPLSTXX' '1100'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'RSTXT-TXLINE(02)'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=TXVB'.
    perform bdc_field       using 'RSTXT-TXLINE(02)'
                                  'GFGFDG'.
    perform bdc_dynpro      using 'SAPLSTXX' '1100'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'RSTXT-TXLINE(02)'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=TXBA'.
    perform bdc_dynpro      using 'SAPMV45A' '4003'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=T\10'.
    perform bdc_dynpro      using 'SAPMV45A' '4003'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'VBKD-POSEX_E'.
    perform bdc_field       using 'VBKD-BSTKD'
                                  'open SO'.
    perform bdc_field       using 'VBKD-BSTDK'
                                  '29.01.2008'.
    perform bdc_field       using 'VBAP-POSEX'
                                  '108128'.
    perform bdc_field       using 'VBKD-BSTKD_E'
                                  '3011192'.
    perform bdc_field       using 'VBKD-POSEX_E'
                                  '000005'.
    perform bdc_dynpro      using 'SAPMV45A' '4003'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/EBACK'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'VBAP-POSEX'.
    perform bdc_field       using 'VBKD-BSTKD'
                                  'open SO'.
    perform bdc_field       using 'VBKD-BSTDK'
                                  '29.01.2008'.
    perform bdc_field       using 'VBAP-POSEX'
                                  '108128'.
    perform bdc_field       using 'VBKD-BSTKD_E'
                                  '3011192'.
    perform bdc_field       using 'VBKD-POSEX_E'
                                  '5'.
    perform bdc_dynpro      using 'SAPMV45A' '4001'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=KKAU'.
    perform bdc_field       using 'VBKD-BSTKD'
                                  'open SO'.
    perform bdc_field       using 'VBKD-BSTDK'
                                  '29.01.2008'.
    perform bdc_field       using 'KUAGV-KUNNR'
                                  '100000'.
    perform bdc_field       using 'KUWEV-KUNNR'
                                  '100000'.
    perform bdc_field       using 'RV45A-KETDAT'
                                  '29.01.2008'.
    perform bdc_field       using 'RV45A-KPRGBZ'
                                  'D'.
    perform bdc_field       using 'VBKD-PRSDT'
                                  '29.01.2008'.
    perform bdc_field       using 'VBKD-INCO1'
                                  'EXW'.
    perform bdc_field       using 'VBKD-INCO2'
                                  'mumbai east'.
    perform bdc_field       using 'VBKD-ZTERM'
                                  '0001'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'RV45A-MABNR(01)'.
    perform bdc_dynpro      using 'SAPMV45A' '4002'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=T\02'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'VBKD-KONDA'.
    perform bdc_field       using 'VBAK-AUDAT'
                                  '29.01.2008'.
    perform bdc_field       using 'VBAK-VKBUR'
                                  'IN15'.
    perform bdc_field       using 'VBAK-WAERK'
                                  'INR'.
    perform bdc_field       using 'VBKD-PRSDT'
                                  '29.01.2008'.
    perform bdc_field       using 'VBKD-KDGRP'
                                  'CF'.
    perform bdc_field       using 'VBKD-PLTYP'
                                  '01'.
    perform bdc_field       using 'VBKD-KONDA'
                                  '01'.
    perform bdc_field       using 'VBKD-BZIRK'
                                  'NORTH'.
    perform bdc_dynpro      using 'SAPMV45A' '4002'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=T\03'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'VBKD-VSART'.
    perform bdc_field       using 'VBAK-VSBED'
                                  '01'.
    perform bdc_field       using 'VBKD-KZAZU'
                                  'X'.
    perform bdc_field       using 'VBKD-VSART'
                                  'ER'.
    perform bdc_dynpro      using 'SAPMV45A' '4002'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=T\05'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'VBKD-INCO2'.
    perform bdc_field       using 'VBKD-INCO1'
                                  'EXW'.
    perform bdc_field       using 'VBKD-INCO2'
                                  'mumbai'.
    perform bdc_field       using 'VBKD-ZTERM'
                                  '0001'.
    perform bdc_field       using 'VBKD-FKDAT'
                                  '29.01.2008'.
    perform bdc_field       using 'VBAK-TAXK1'
                                  '1'.
    perform bdc_field       using 'VBAK-TAXK3'
                                  'l'.
    perform bdc_dynpro      using 'SAPMV45A' '4002'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=T\09'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'VBKD-ZLSCH'.
    perform bdc_field       using 'VBKD-KTGRD'
                                  '01'.
    perform bdc_field       using 'VBKD-ZLSCH'
                                  'c'.
    perform bdc_dynpro      using 'SAPMV45A' '4002'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=TP_DELETE'.
    perform bdc_field       using 'LV70T-SPRAS'
                                  'EN'.
    perform bdc_dynpro      using 'SAPMV45A' '4002'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=TP_CREATE'.
    perform bdc_field       using 'LV70T-SPRAS'
                                  'EN'.
    perform bdc_dynpro      using 'SAPMV45A' '4002'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=TP_DETAIL'.
    perform bdc_field       using 'LV70T-SPRAS'
                                  'EN'.
    perform bdc_dynpro      using 'SAPLSTXX' '1100'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'RSTXT-TXLINE(02)'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=TXVB'.
    perform bdc_field       using 'RSTXT-TXLINE(02)'
                                  'BDFBFDB'.
    perform bdc_dynpro      using 'SAPLSTXX' '1100'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'RSTXT-TXLINE(02)'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=TXBA'.
    perform bdc_dynpro      using 'SAPMV45A' '4002'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=T\11'.
    perform bdc_dynpro      using 'SAPMV45A' '4002'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=KSTC'.
    perform bdc_dynpro      using 'SAPLBSVA' '0300'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'J_STMAINT-ANWS(02)'.
    perform bdc_field       using 'J_STMAINT-ANWS(01)'
    perform bdc_field       using 'J_STMAINT-ANWS(02)'
                                  'X'.
    perform bdc_dynpro      using 'SAPLBSVA' '0300'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'J_STMAINT-ANWS(03)'.
    perform bdc_field       using 'J_STMAINT-ANWS(02)'
    perform bdc_field       using 'J_STMAINT-ANWS(03)'
                                  'X'.
    perform bdc_dynpro      using 'SAPLBSVA' '0300'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'J_STMAINT-ANWS(04)'.
    perform bdc_field       using 'J_STMAINT-ANWS(03)'
    perform bdc_field       using 'J_STMAINT-ANWS(04)'
                                  'X'.
    perform bdc_dynpro      using 'SAPLBSVA' '0300'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=BACK'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'JOSTD-OBJNR'.
    perform bdc_dynpro      using 'SAPMV45A' '4002'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/EBACK'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'RV45A-TXT_VBELN'.
    perform bdc_dynpro      using 'SAPMV45A' '4001'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=SICH'.
    perform bdc_field       using 'VBKD-BSTKD'
                                  'open SO'.
    perform bdc_field       using 'VBKD-BSTDK'
                                  '29.01.2008'.
    perform bdc_field       using 'KUAGV-KUNNR'
                                  '100000'.
    perform bdc_field       using 'KUWEV-KUNNR'
                                  '100000'.
    perform bdc_field       using 'RV45A-KETDAT'
                                  '29.01.2008'.
    perform bdc_field       using 'RV45A-KPRGBZ'
                                  'D'.
    perform bdc_field       using 'VBKD-PRSDT'
                                  '29.01.2008'.
    perform bdc_field       using 'VBKD-INCO1'
                                  'EXW'.
    perform bdc_field       using 'VBKD-INCO2'
                                  'mumbai'.
    perform bdc_field       using 'VBKD-ZTERM'
                                  '0001'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'RV45A-MABNR(01)'.
    perform bdc_transaction using 'VA01'.
    perform close_group.
    if in excel file one row of records means i am succesfully creating SO.
    But for multiple i am not getting idea to create SO.
    My excel file details like this.In this excel file based on VBKD-BSTKD_E value i have to keep the records in line items.
    VBAK-AUART    :Order Type
    VBAK-VKORG    : Sales Org
    VBAK-VTWEG    : Distri Channel
    VBAK-SPART    : Division
    VBAK-KUNNR    : Sold-to-Party
    VBPA-KUNNAR   : Ship-to-Party
    VBAK-BSTNK    : PO No
    VBAK-BSTDK    : PO Date
    VBAP-MATNR    : Material No
    A_THICK_MM
    A_WIDTH_MM
    A_EQUIVALENT_SPEC
    A_COIL_INNER_DIA_MM
    A_BATCH_WEIGHT_MIN_SI
    A_BATCH_WEIGHT_MAX_SI
    VBAP-KWMENG    : Qty
    VBAP-WERKS     : Delivery Plant
    VBKD-INCO2     : Incoterm2
    VBKD-KONDA     : Price Group
    VBKD-VSART     : Shipping Type
    VBAK-TAXK1     : Cust Tax-1
    VBAK-TAXK2     : Cust Tax-2
    VBAK-TAXK3     : Cust Tax-3
    VBAK-TAXK4     : Cust Tax-4
    VBKD-ZLSCH     : Payment Method
    VBAP-TAXM1     : Mat tax clss-1
    VBAP-TAXM2     : Mat tax clss-2
    VBAP-TAXM3     : Mat tax clss-3
    VBAP-TAXM4     : Mat tax clss-4
    VBAP-POSEX     : IMPS Order No
    VBKD-BSTKD_E   : old SO in 4.6c
    VBKD-POSEX_E   : old SO Item  in 4.6c
    Text Id        : TDC No
    Text Id-ES10   : Special Inst(Unld const & Veh)
    ZOR,2000,10,5,100000,100000,PO NO 125,19.01.2008,HRPOCF,3.1,1200,IS_11513_GR_D_1985,610,20.084,20.084
    51,2010,Mumbai,01Freight-pre paid,ER,2,0,L,0,c,1,1,0,0,108128,3011192,     1,PO 444 AMD 1,Spl Inst
    based on VBKD-BSTKD_E line items has to create.
    if VBKD-BSTKD_E = 3011192 is like 4 records in excel means for these 4 should be one SO
    if it is changed to 3011193 then only different SO.
    PLs If any one knows solution pls write some sample code for me.
    If u send that code to my mail id also  very thankful.
    [email protected]
    Pls help me this is urgent requirement.
    Thanks & Regards,
    J.Lokesh

    HI,
    Instead of using BDC , why dont you make use of BAPI.
    As you are on ECC, you can make use of BAPI BAPI_SALESORDER_CREATEFROMDAT2
    Collect all your records based on PO # and pass them into line item table structure ORDER_ITEMS_IN.
    *--Logic something like this.
      loop at it_exceldata into l_line.
      loop at it_exceldata into l_so where bstkd_e eq l_line-bstkd.
      *This will loop at all the same  PO#
      *collect the data related into corr tables. and append
      endloop.
      *Now you are outside the loop.
      *Call the BAPI to update this SO
      delete it_exceldata where bstkd_e eq l_line-bstkd_e.
      endloop.
    Also pass all the necessary data to header structure ORDER_HEADER_IN
    Do not check for Sy-subrc at the end of execution.
    Instead read the Return table with message type 'A' or 'E whichi means there is an error/abort in BAPI execution.
    Remember to expicitly COMMIT_WORK after succesfull execution of BAPI using BAPI_TRANSACTION_COMMIT
    Please let me know , if you need more help in this
    Gary.

  • BDC for multiple line items (VA01)

    Hi Experts,
      I create a BDC for VA01 transaction for single line item in that now i want to upload multiple line items also with  o/p of total no. of records uploaded, no. of records posted and the no. of error records...
    Can any body explain with sample code...

    Hi,
    if the flat file is containing header and item records...
    first split those records tooo two internal tables header and item..
    Loop at header ...
      process of recording steps for header....
    Loop at item...
    here create a varialbe with char 2 .. for index value....
      process of item recording steps..
      increment the index value by 1....
      here u have to pass  'p+'  OK_CODE..
    Endloop ..(item)
    Endloop...(header)
    for more info goo through this link...
    http://www.sap-img.com/bdc.htm
    hope helpful
    Raghunath.S

  • Problem in the BDC Table Control for the T.Code VA01

    Hi,
      I faced probelm in the BDC of the VA01. In the Table Control
    the records are entered upto 12 line items. after 13th line item overwrites the first record. How to solve the Problem.
    Please help me.

    or use this
    Internal table definition *
    data : begin of bdcdata occurs 0.
            include structure bdcdata.
    data : end of bdcdata.
    data: begin of messtab occurs 0.
            include structure bdcmsgcoll.
    data: end of messtab.
    data: v_chr_opengrp type c,
          r_matnr like mara-matnr,                       "variable for material conversion
          r_werks like marc-werks,                       "variable for plant
          v_str_fname   type string.
    data: begin of count2,
          inrec(9) type n,                               " input I_MATERIAL count
          create(9) type n,                              " create count
          error(9) type n,                               " error count
          bdc(9) type n,                                 " count of BDC creates
          end of count2.
    types: begin of ty_source,
    partn_numb(10) type n ,"Customer Number 1
    ref(035),
    sales_org(4) , "Sales Organization
    distr_chan(2) , "Distribution Channel
    division(002), "DIVISION
    doc_type(4) , "Sales Document Type
    purch_no(020), "Purchase order
    material like vbap-matnr,
    reqqty(018),
    reqdate(010),
    end of ty_source,
    begin of ty_header ,
    partn_numb(10) ,"Customer Number 1
    ref(035),
    sales_org(4) , "Sales Organization
    distr_chan(2) , "Distribution Channel
    division(002), "DIVISION
    doc_type(4) , "Sales Document Type
    purch_no(020), "Purchase order
    end of ty_header,
    begin of ty_item,
    partn_numb(10) ,"Customer Number 1
    ref(035),
    material like vbap-matnr,
    reqqty(018),
    reqdate(010),
    end of ty_item.
    data : msg(240) type c, " Return Message
    e_rec(8) type c, " Error Records Counter
    rec_no(8) type c, " Records Number Indicator
    s_rec(8) type c, " Successful Records Counter
    t_rec(8) type c, " Total Records Counter
    v_matnr like mara-matnr.
    data: val(2) type n value 01.
    data : begin of bdc_itab occurs 0.
            include structure bdcdata.
    data : end of bdc_itab.
    data : t_source type standard table of ty_source   with header line,
    t_header type standard table of ty_header initial size 1,
    t_item type standard table of ty_item initial size 1,
    t_target type standard table of bdcdata initial size 1.
    data : w_source type ty_source,
    w_source1 type ty_source,
    w_header type ty_header,
    w_item type ty_item,
    w_target type bdcdata,
    count type i,
    count1 type n.
    Variable Declaration
    data: w_fname type string,
    fnam(20),
    date1(10),
    i(2) type n,
    v_count type i,
    v_group type apqi-groupid.
    *& selection screen
    selection-screen :begin of block bl1 with frame title  text-001.
    parameters : p_fname type rlgrap-filename,                         "Input file
                 p_update(1) default 'N',                              "Input for update mode
                 p_bdcgrp(12) default 'SD_ORDERS'.                     "Input for session name
    selection-screen end of block bl1.
    **&SELECTION SCREEN VALIDATIONS
    at selection-screen on value-request for p_fname.
      call function 'KD_GET_FILENAME_ON_F4'
        exporting
          program_name  = 'ZMATERIAL'
          dynpro_number = '1000'
          field_name    = 'P_FNAME'
        changing
          file_name     = p_fname.
    *& Start of selection
    start-of-selection.
      if  p_fname is initial.
        message i016(rp) with 'Please enter a file name'.
        leave list-processing.
      else.
        move p_fname to  v_str_fname.
      endif.
      call function 'GUI_UPLOAD'
        exporting
          filetype                = 'ASC'
          filename                = v_str_fname
          has_field_separator     = 'X'
        tables
          data_tab                = t_source
        exceptions
          file_open_error         = 1
          file_read_error         = 2
          no_batch                = 3
          gui_refuse_filetransfer = 4
          invalid_type            = 5
          no_authority            = 6
          unknown_error           = 7
          bad_data_format         = 8
          header_not_allowed      = 9
          separator_not_allowed   = 10
          header_too_long         = 11
          unknown_dp_error        = 12
          access_denied           = 13
          dp_out_of_memory        = 14
          disk_full               = 15
          dp_timeout              = 16
          others                  = 17.
      if sy-subrc <> 0.
        message id sy-msgid type sy-msgty number sy-msgno
            with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      endif.
      sort t_source by ref partn_numb.
      loop at t_source into w_source.
        add 1 to count2-inrec.
        w_source1 = w_source.
       AT NEW PARTN_NUMB.  "10/31 KVB
        at new ref.
          w_header-doc_type = w_source1-doc_type..
          w_header-sales_org = w_source1-sales_org .            "'0001'
          w_header-distr_chan = w_source1-distr_chan.           "'01'
          w_header-division = w_source1-division.               " '01'
          w_header-purch_no = w_source1-purch_no.
          w_header-partn_numb = w_source1-partn_numb.
          w_header-ref = w_source1-ref.
          append w_header to t_header.
        endat.
        w_item-partn_numb = w_source1-partn_numb.
        w_item-material = w_source1-material.
        w_item-reqqty = w_source1-reqqty.
        w_item-ref = w_source1-ref.
        w_item-reqdate = w_source1-reqdate.
        append w_item to t_item.
        clear :w_item,w_header.
      endloop.
      loop at t_header into w_header.
        perform bdc_dynpro      using         'SAPMV45A'                  '0101'       .
        perform bdc_field       using         'BDC_CURSOR'                'VBAK-SPART'.
        perform bdc_field       using         'BDC_OKCODE'                '/00'.
        perform bdc_field       using         'VBAK-AUART'                w_header-doc_type.
        perform bdc_field       using         'VBAK-VKORG'                w_header-sales_org.
        perform bdc_field       using         'VBAK-VTWEG'                w_header-distr_chan.
        perform bdc_field       using         'VBAK-SPART'                w_header-division.
        perform bdc_dynpro      using         'SAPMV45A'                  '4001'     .
        perform bdc_field       using         'BDC_OKCODE'                '/00'.
        perform bdc_field       using         'BDC_CURSOR'               'VBKD-BSTKD'.
        perform bdc_field       using         'VBKD-BSTKD'                w_header-purch_no.
        perform bdc_field       using         'KUWEV-KUNNR'               w_header-partn_numb.
        i = 1.
        loop at t_item into w_item where partn_numb = w_header-partn_numb
                                         and ref = w_header-ref.
          at new partn_numb.
            clear count1.
            count = 0.
          endat.
          count = count + 1.
          if count gt 5.
            clear i.
            i = 2.
            perform bdc_dynpro      using 'SAPMV45A' '4001'      .
            perform bdc_field       using 'BDC_OKCODE' '=POAN'.
          endif.
          count1 = count1 + 1.
          concatenate 'VBAP-POSNR(' i ')' into fnam.
          perform bdc_field       using  fnam
                                        count1.
          concatenate 'RV45A-MABNR(' i ')' into fnam.
          perform bdc_field    using fnam                            w_item-material.
          concatenate 'RV45A-KWMENG(' i ')' into fnam.
          perform bdc_field       using  fnam                        w_item-reqqty..
          concatenate 'RV45A-ETDAT(' i ')' into fnam.
          perform bdc_field       using  fnam                         w_item-reqdate.
          concatenate 'VBKD-BSTKD_E(' i ')' into fnam.
          perform bdc_field       using  fnam                         w_item-ref.
          i = i + 1.
          clear:  w_item.
        endloop.
        clear w_header.
        perform bdc_dynpro      using 'SAPMV45A' '4001'.
        perform bdc_field       using 'BDC_OKCODE'
                                      '=SICH'.
        perform post_transaction.
        refresh bdc_itab.
        clear   bdc_itab.
      endloop.
    *endloop.
    end-of-selection.
      perform finalization.
           Start new screen                                              *
    form bdc_dynpro using program dynpro.
      clear bdc_itab.
      bdc_itab-program  = program.
      bdc_itab-dynpro   = dynpro.
      bdc_itab-dynbegin = 'X'.
      append bdc_itab.
    endform.                    "bdc_dynpro
           Insert field                                                  *
    form bdc_field using fnam fval.
      if fval <> ''.
        clear bdc_itab.
        bdc_itab-fnam = fnam.
        bdc_itab-fval = fval.
        append bdc_itab.
      endif.
    endform.                    "bdc_field
    **&      Form  get_filename
          text
    -->  p1        text
    <--  p2        text
    *form get_filename .
    *call function 'WS_FILENAME_GET'
       exporting
         def_filename     = space
         def_path         = file
         mask             = ',.,..'
         mode             = 'N'
         title            = text-015
       importing
         filename         = file
       exceptions
         inv_winsys       = 1
         no_batch         = 2
         selection_cancel = 3
         selection_error  = 4
         others           = 5.
    *endform.                    " get_filename
    *&      Form  post_transaction
          text
    -->  p1        text
    <--  p2        text
    form post_transaction .
      refresh messtab.
      clear   messtab.
      call transaction  'VA01' using bdc_itab
                  mode   p_update
                update  'S'
              messages into messtab.
      read table messtab with key msgtyp = 'E'.
      if sy-subrc eq 0.
        perform process_error_messages.
        add 1 to count2-bdc.
        if v_chr_opengrp is initial.
          perform bdc_open_group.
        endif.
        call function 'BDC_INSERT'
          exporting
            tcode          = 'VA01'
          tables
            dynprotab      = bdc_itab
          exceptions
            internal_error = 1
            not_open       = 2
            queue_error    = 3
            tcode_invalid  = 4
            others         = 5.
        if sy-subrc <> 0.
          case sy-subrc.
            when 1.
              write: / 'Internal error'.
            when 2.
              write: / 'Not open error'.
            when 3.
              write: / 'queue error'.
            when 4.
              write: / 'tcode invalid error'.
            when others.
              write: / 'other error'.
          endcase.
        endif.
      else.
        add +1 to count2-create.
        format intensified off.
        format color col_normal.
        format color col_normal off.
      endif.
      clear   bdc_itab.
      refresh bdc_itab.
    endform.                    " post_transaction
    *&      Form  finalization
          text
    -->  p1        text
    <--  p2        text
    form finalization .
      if v_chr_opengrp = 'X'.
        call function 'BDC_CLOSE_GROUP'
          exceptions
            not_open    = 1
            queue_error = 2
            others      = 3.
      endif.
      get time.
      skip 2.
      write: / 'Time', sy-uzeit.
      skip.
      format color col_total on.
      write: / 'Total Records: ',           40 count2-inrec.
      write: / 'PERNR not of Emp Group 6 ', 40 count2-error.
      write: / 'Records Created: ',         40 count2-create.
      write: / 'BDC Create in group: ',     40 count2-bdc.
      if v_chr_opengrp = 'X'.
        skip 1.
        format intensified on.
        format color col_negative on.
        write: / 'PLEASE USE TRANSACTION "SM35" ',
                 'TO PROCESS THE GENERATED BDC SESSION ... ',
                 p_bdcgrp.
      endif.
    endform.                    " finalization
    *&      Form  bdc_open_group
          text
    -->  p1        text
    <--  p2        text
    form bdc_open_group .
      call function 'BDC_OPEN_GROUP'
        exporting
          client              = sy-mandt
          group               = p_bdcgrp
          holddate            = sy-datum
          keep                = 'X'
          user                = sy-uname
        exceptions
          client_invalid      = 1
          destination_invalid = 2
          group_invalid       = 3
          group_is_locked     = 4
          holddate_invalid    = 5
          internal_error      = 6
          queue_error         = 7
          running             = 8
          system_lock_error   = 9
          user_invalid        = 10
          others              = 11.
      if sy-subrc eq 0.
        v_chr_opengrp = 'X'.
      endif.
    endform.                    " bdc_open_group
    *&      Form  process_error_messages
          text
    -->  p1        text
    <--  p2        text
    form process_error_messages .
      data: begin of loc_aux_message.
              include structure message.
      data: end of loc_aux_message.
      data : msgno type sy-msgno.
      loop at messtab.
        move messtab-msgnr to msgno.
        call function 'WRITE_MESSAGE'
          exporting
            msgid  = messtab-msgid
            msgno  = msgno
            msgty  = messtab-msgtyp
            msgv1  = messtab-msgv1
            msgv2  = messtab-msgv2
            msgv3  = messtab-msgv3
            msgv4  = messtab-msgv4
          importing
            messg  = loc_aux_message
          exceptions
            others = 1.
        if sy-subrc eq 0.
          format color col_negative on.
          write: /10 loc_aux_message.
          format color col_negative off.
        else.
          format color col_negative on.
          write: /10 t_source-partn_numb.
          write: / 'Error creating message'.
          format color col_negative off.
          exit.
        endif.
      endloop.
    endform.                    " process_error_messages

  • VA01 BDC Session - Purchase requisition wiew not shown

    Hello Forum,
    I've a problem with a BDC session in ECC 6.0 about VA01. When I try to change the purchasing requisition data from the shcedule tab using the button identified from the BDC with the code "EIBB"  (the last one) the subsequent screen is not shown from the system. If I try to create manually a new sales order I'm able to view the screen.
    I tried to remake the recording in 4.6C and the screen is shown correctly.
    I'm in a mock conversion and in UAT but I wasn't able to find the problem.
    Can you suggest something << Moderator message - Everyone's problem is important >>?
    Many Thanks.
    Regards.
    Edited by: Rob Burbank on Oct 19, 2010 3:20 PM

    Thanks Anyway, but with an additional search I've found the solution Here.
    Batch input VA01 problem

  • BDC using SAVE text in VA01

    Hi All,
    I'm creating a BDC session calling the VA01.
    my problem is where do I put my code? I test it and I still got a blank in header text pick list.
    Codes is more helpful so I can compare my work.
    Thanks.

    here is my code for BDC.
    data: begin of record,
            TXLINE_02_028(072),
           end of record.
    ****MESLAN
      clear: v_itm, v_kwmeng, v_mabnr.
      LOOP AT t_hdr .
    *-- HEADER
        PERFORM fill_dynpro USING 'SAPMV45A'    '0101' 'X'.
        PERFORM fill_field USING: 'VBAK-AUART'  p_auart,
                                  'VBAK-VKORG'  t_hdr-vkorg,
                                  'VBAK-VTWEG'  t_hdr-vtweg,
                                  'VBAK-SPART'  t_hdr-spart,
                                  'BDC_OKCODE'  '/00'.
        PERFORM fill_dynpro USING 'SAPMV45A'      '4001' 'X'.
        PERFORM fill_field USING: 'VBKD-BSTKD'   t_hdr-bstnk,
                         'KUAGV-KUNNR'  t_hdr-ablad,
                         'RV45A-KPRGBZ' 'D',
                         'VBAK-LIFSK'   p_lifsk,
                         'VBAK-AUGRU'   p_augru,
                         'BDC_OKCODE'   '/00'.
        PERFORM fill_dynpro USING 'SAPMV45A'      '4001' 'X'.
        PERFORM fill_field USING:  'VBKD-BSTKD'    t_hdr-bstnk,
                                   'KUAGV-KUNNR'  t_hdr-ablad,
                                   'KUWEV-KUNNR'  t_hdr-ablad,
                                   'RV45A-KPRGBZ' 'D',
                                   'VBAK-LIFSK'   p_lifsk,
                                   'VBAK-AUGRU'   p_augru,
                                   'BDC_OKCODE'   '=KBES'.
        PERFORM fill_dynpro USING 'SAPMV45A'     '4002' 'X'.
        PERFORM fill_field USING:  'VBKD-BSTKD'  t_hdr-bstnk,
                        'VBKD-BSARK'  P_BSARK,
                        'BDC_OKCODE'  '/00'.
        PERFORM fill_dynpro USING 'SAPMV45A'    '4002' 'X'.
        PERFORM fill_field USING: 'VBKD-BSTKD'    t_hdr-bstnk,
                       'VBKD-BSARK'   P_BSARK,
                       'BDC_OKCODE'   '/EBACK'.
        PERFORM fill_dynpro USING 'SAPMV45A'    '4001' 'X'.
        PERFORM fill_field USING: 'VBKD-BSTKD'    t_hdr-bstnk,
                       'KUAGV-KUNNR'  t_hdr-ablad,
                       'KUWEV-KUNNR'  t_hdr-ablad,
                       'RV45A-KPRGBZ' 'D',
                       'VBAK-LIFSK'    p_lifsk,
                       'VBAK-AUGRU'    p_augru,
                       'BDC_OKCODE'    '=POAN'.
        LOOP AT t_line WHERE bstnk EQ t_hdr-bstnk .  " Select all line items
    *-- LINE ITEMS
          CONCATENATE 'RV45A-MABNR(' '0' VAL ')'  INTO v_MABNR.
          CONCATENATE 'RV45A-KWMENG(' '0' VAL ')' INTO v_kwmeng.
          PERFORM fill_dynpro USING 'SAPMV45A'   '4001' 'X'.
          PERFORM fill_field USING: 'VBKD-BSTKD'  t_hdr-bstnk,
                               'KUAGV-KUNNR'  t_hdr-ablad,
                               'KUWEV-KUNNR'  t_hdr-ablad,
                               'RV45A-KPRGBZ' 'D',
                               'VBAK-LIFSK'   p_lifsk,
                               'VBAK-AUGRU'   p_augru,
                          v_MABNR        t_line-matnr,
                           v_kwmeng     t_line-kwmeng,
                             'BDC_OKCODE'   '/00'.
    *---- for t_curlin
          v_itm = val * 10 .
          t_curlin = t_line.
          t_curlin-lineno = v_itm .
          APPEND t_curlin .
    *---- for line item
          VAL = VAL + 1.
        endloop.
        VAL = 01.
        PERFORM fill_dynpro USING 'SAPMV45A'    '4001' 'X'.
        PERFORM fill_field USING:      'VBKD-BSTKD'       t_hdr-bstnk,
                             'KUAGV-KUNNR'  t_hdr-ablad,
                             'KUWEV-KUNNR'  t_hdr-ablad,
                             'RV45A-KPRGBZ' 'D',
                             'VBAK-LIFSK'   p_lifsk,
                             'VBAK-AUGRU'   p_augru,
                                 'BDC_OKCODE'       '=SICH'.
        CALL TRANSACTION 'VA01' USING t_bdctab
                                     MODE p_mode
                                     UPDATE c_s
                                     MESSAGES  INTO t_message .
        IF sy-subrc NE 0 .         " Post errored sessions- for correction
          v_errflg = c_x .         " Online posting error - open session
          v_errno  = v_errno + 1 .
          PERFORM append_mail_table .
          PERFORM open_session .
          CALL FUNCTION 'BDC_INSERT'
               EXPORTING
                   tcode            =  'VA01'                   "c_va01
               POST_LOCAL       = NOVBLOCAL
               PRINTING         = NOPRINT
               TABLES
                    dynprotab        = t_bdctab
               EXCEPTIONS
                    internal_error   = 1
                    not_open         = 2
                    queue_error      = 3
                    tcode_invalid    = 4
                    printing_invalid = 5
                    posting_invalid  = 6
                    OTHERS           = 7.
        ELSE .
          t_text-tdline = t_hdr-text .
          APPEND t_text .
          CLEAR t_text .
          WRITE sy-msgv2 TO v_vbeln RIGHT-JUSTIFIED .
          TRANSLATE v_vbeln USING c_0 .
          v_tdname = v_vbeln .             "' order no.
          CALL FUNCTION 'CREATE_TEXT'
                EXPORTING
                     fid         = c_z961
                     flanguage   = p_spras
                     fname       = v_tdname
                     fobject     = c_vbbk
                    save_direct  = c_x
            FFORMAT     = '*'
                TABLES
                     flines      = t_text
                EXCEPTIONS
                     no_init     = 1
                     no_save     = 2
                     OTHERS      = 3.
          CLEAR t_text . REFRESH t_text .
          IF sy-subrc NE 0 .
            WRITE : / c_er_load , v_tdname .
          ENDIF .
          v_succno = v_succno + 1 .
        ENDIF .
        CLEAR t_bdctab . REFRESH t_bdctab .
      endloop.
      IF v_errflg EQ c_x .
        CALL FUNCTION 'BDC_CLOSE_GROUP'
             EXCEPTIONS
                  not_open    = 1
                  queue_error = 2
                  OTHERS      = 3.
        IF sy-subrc EQ 0 .
          MESSAGE i260(zo) WITH text-i01.
        ENDIF .
      ENDIF .
    ENDFORM.

  • Problem to generate same VA01 search help screen in BDC Program

    Hi All,
              I have got one issue.
              The issue is that i need to generate the search (F4) help screen of VA01 search for articles in the program,.
              I tried to record using BDC, but the screen generated is different.
              Can anyone please guide me how to generate that same search help screen in Program using BDC or any other tool.

    Hi
    Just check the field in the VA01 for which you are using BDC , you may get the standard search help for that .
    It wuld be great if you elaborate your requierment .
    Regards
    Rahul

  • BDC Uploading from flat file to VA01.

    i have a flat file, where i have to upload data  into VA01, but it should suppose to multiple materials under same customer and it should not get saved until end user decide whether data is ok or not. my problem is, how to make multiple entries of diff materials in VA01 for single customer. Please give me any solution, and if possible provide me any examples. thank you.

    Hi Kalyan,
    Here is the sample code for you ....... but i tis better you use the BAPI
    <b>BAPI_SALESORDER_CREATEFROMDAT1 or BAPI_SALESORDER_CREATEFROMDAT2</b>
    REPORT ZSD00001 MESSAGE-ID ZZ.
    TABLES: VBAK, VBAP.
    TABLES: ZSOM1, ZSOM2.
    SELECTION-SCREEN: BEGIN OF BLOCK FORT WITH FRAME TITLE TEXT-002.
    PARAMETERS: P_FILE RADIOBUTTON GROUP B2 DEFAULT 'X',
                P_TABLE RADIOBUTTON GROUP B2,
                P_REPORT RADIOBUTTON GROUP B2.
    SELECTION-SCREEN SKIP 1.
    PARAMETER: VIEW RADIOBUTTON GROUP VIEW,
               ERRORS RADIOBUTTON GROUP VIEW,
               NO_DIS RADIOBUTTON GROUP VIEW DEFAULT 'X'.
    SELECTION-SCREEN: END OF BLOCK FORT.
    SELECTION-SCREEN: BEGIN OF BLOCK FILE WITH FRAME TITLE TEXT-001.
    PARAMETERS:
                IDLEX RADIOBUTTON GROUP B1 DEFAULT 'X',
                DBLEX RADIOBUTTON GROUP B1,
                BDC_NAME(12)     TYPE C DEFAULT 'idllapso',
                IDLH(99)         TYPE C DEFAULT
            '/usr/sap/D01/DVEBMGS00/ISAP/interfaces/laptop/in/idlordht.txt',
                IDLI(99)         TYPE C DEFAULT
            '/usr/sap/D01/DVEBMGS00/ISAP/interfaces/laptop/in/idlordit.txt',
                ARC_FIL DEFAULT ' ' AS CHECKBOX.
    SELECTION-SCREEN: END OF BLOCK FILE.
    SELECTION-SCREEN: BEGIN OF BLOCK TAB WITH FRAME TITLE TEXT-003.
    SELECT-OPTIONS: O_IHREZ FOR ZSOM1-IHREZ,
                    O_VBELN FOR ZSOM1-IHREZ,
                    O_MESS FOR ZSOM1-MESS DEFAULT 'W'.
    SELECTION-SCREEN: END OF BLOCK TAB.
    DATA:
    * Data counters.
           RECS_IN(4)            TYPE N  VALUE 0,
           BDC_RECS_OUT(4)       TYPE N  VALUE 0,
           BDC_RECS_ERR(4)       TYPE N  VALUE 0,
           DATA_IN_RECS(4)        TYPE N  VALUE 0,
    * Data constants
           TRUE(1)               TYPE C  VALUE 'X',
           FALSE(1)              TYPE C  VALUE ' ',
    * Data variables
           ABAPNAME              LIKE SY-REPID,
           ABAPTITLE             LIKE SY-TITLE,
           SAVE_UCOMM            LIKE SY-UCOMM,
           V_IHREZ               LIKE VBAK-IHREZ.
    * inbound header structure
    DATA: BEGIN OF IDLORDH OCCURS 1000,
    SO-NUMBER(5)          TYPE N,  "The order number given by the Vax - Alwa
    ORDER-TYPE(1)         TYPE N,  "1 - Under-Bond Sale  3 - Duty-Paid Order
    CUST-NO(7)            TYPE N,          "Id for customer
    BRANCH-NO(4)          TYPE N,          "Id of customer's branch
    PC-DATE-REQD(8)       TYPE C,  "Date that customer required the order
    IDL-ORDER-NO(5)       TYPE N,          "Laptop's Order Number
    SPEC-INS-1(40)        TYPE C,  "Text detailing special instruction for t
    SPEC-INS-2(40)        TYPE C,          "Part 2 of above
    PC-ORDER-DATE(8)      TYPE C,  "Date order was entered on the Laptop
    ORDER-METHOD(1)       TYPE N,          "Always 5 for laptop
    FOR-COLLECTION(1)     TYPE C,  "Y if customers is collecting order else
    CASH-RECEIVED(9)      TYPE N,          "N/A
    CASH-SHEET-NO(6)      TYPE N,          "N/A
    CUST-ORDER-NO(14)     TYPE C,  "Customers Order Number - Optional
    HOLD-FOR-PRICING(1)   TYPE C,  "Y if this order is held because no price
    PC-PRICE-EFF-DATE(8)  TYPE C,          "Defaults to order date
    NO-ITEMS(4)           TYPE N,  "Number of items for this order in detail
    TOTAL-QTY-ORDERED(9)  TYPE N,          "Number of cases on this order
    TOTAL-CE-ORDERED(9)   TYPE N,  "Number of case equivalents on this order
    ORDER-STATUS(1)       TYPE N,          "Always 0 for new orders
    SITE-PREFIX(1)        TYPE C,  "Plant from where the delivery will be ma
    PC-USER-NO(3)         TYPE N.          "laptop user who crested order
    DATA: END OF IDLORDH.
    DATA: BEGIN OF IDLORDI OCCURS 1000,
    SO-NUMBER(5)         TYPE N,  "The order number given by the Vax - Alway
    ORDER-ENTRY-CODE(5)  TYPE N,           "Part Id
    PC-DATE-REQD(8)      TYPE C,  "Date the customer required order.
    QTY-TO-ORDER(4)      TYPE N,           "Number of units on the order.
    PC-USER-NO(3)        TYPE N,           "Id of rep. Who created the order
    IDL-ORDER-NO(5)      TYPE N,           "Laptop's Order Number
    FREE-QTY-ORDERED(4)  TYPE N,  "Number of free units on the order.
    PROMOTION-NO(4)      TYPE N.  "If Free units on the order, this is promo
    DATA: END OF IDLORDI.
    * Internal table to hold the mapped data.
    DATA:  BEGIN OF DATA_IN OCCURS 1000,
              RTYPE(1) TYPE C,
    * header
              AUART LIKE VBAK-AUART,       "order type
              VKORG LIKE VBAK-VKORG,       "sales org
              VTWEG LIKE VBAK-VTWEG,       "dist.channel
              SPART LIKE VBAK-SPART,       "division
              KUNNR LIKE KUAGV-KUNNR,      "customer num
    *         vkbur like vbak-vkbur,  "sales off
    *         vkgrp like vbak-vkgrp,  "sales grp
              BSTNK LIKE VBAK-BSTNK,       "po num
              IHREZ LIKE VBAK-IHREZ,       "po reference
              BSTDK LIKE VBAK-BSTDK,       "po date
              KPRGBZ  LIKE RV45A-KPRGBZ,   "date type
    *         ketdat  like rv45a-ketdat, "req delivery date
              KETDAT(8) TYPE C         ,   "req delivery date
              PRSDT    LIKE VBKD-PRSDT,    "pricing date
              LIFSK   LIKE VBAK-LIFSK,     "delivery block
              INCO1   LIKE  VBKD-INCO1,    "inco terms
              INCO2   LIKE VBKD-INCO2,     "inco descript.
              FAKSK   LIKE VBAK-FAKSK,     "biling block
              KUNDE   LIKE RV02P-KUNDE,    "shipto
              ltext1(256) type c,          "Special text1
              ltext2(256) type c,          "Special text2
              BSARK    LIKE VBAK-BSARK,    "ordering method
              BNAME    LIKE VBAK-BNAME,    "orderer
              WERKS LIKE VBAP-WERKS,       "Site Prefix
    * item
              POSNR LIKE VBAP-POSNR,       "item
              MATNR LIKE VBAP-MATNR,       "material
              MENGE(15) TYPE C,                                 "qty
              FREE_MENGE(15) TYPE C,       "Free qty ordered
              PSTYV LIKE VBAP-PSTYV,       "item category
              ROUTE LIKE VBAP-ROUTE,       "Collect or not
    *         vrkme(3) type c,        "uom
    *         itext(40),              "item txt
    END OF DATA_IN.
    DATA: BEGIN OF I_MATERIAL OCCURS 0,
          MATNR LIKE MARA-MATNR,
          ORDER LIKE IDLORDI-ORDER-ENTRY-CODE,
          END OF I_MATERIAL.
    DATA: BEGIN OF I_MAIL OCCURS 0.
          INCLUDE STRUCTURE SOLI.
    DATA: END OF I_MAIL.
    * Internal table to contain BDC data.
    DATA: BEGIN OF BDCDATA OCCURS 1000.
            INCLUDE STRUCTURE BDCDATA.
    DATA: END OF BDCDATA.
    DATA: BEGIN OF MESSTAB OCCURS 0.
            INCLUDE STRUCTURE BDCMSGCOLL.
    DATA: END OF MESSTAB.
    DATA: BEGIN OF I_OUTPUT OCCURS 1000.
            INCLUDE STRUCTURE DATA_IN.
    DATA: END OF I_OUTPUT.
    DATA: OLD_RTYPE LIKE DATA_IN-RTYPE,
          V_VBELN LIKE VBAK-VBELN,
          V_ITEM_NO(2) TYPE N,
          V_MAIL(1) TYPE C,
          V_VIEW(1) TYPE C,
          V_IDL-ORDER-NO LIKE IDLORDH-IDL-ORDER-NO,
          V_PC-USER-NO LIKE IDLORDH-PC-USER-NO.
    AT SELECTION-SCREEN.
    * Check name of BDC session has been supplied.
      IF BDC_NAME EQ SPACE.
        SET CURSOR FIELD 'BDC_NAME'.
        MESSAGE E002 WITH 'No batch-input session name supplied'.
      ENDIF.
    START-OF-SELECTION.
      MOVE: SY-REPID TO ABAPNAME,
            SY-TITLE TO ABAPTITLE.
      IF VIEW  = 'X'. V_VIEW = 'A'. ENDIF.
      IF ERRORS  = 'X'. V_VIEW = 'E'. ENDIF.
      IF NO_DIS  = 'X'. V_VIEW = 'N'. ENDIF.
      IF P_FILE = 'X'.
    * Read the input files.
        PERFORM READ_FILES.
    * Map the data.
        PERFORM MAP_DATA.
    * Create the BDC sessions.
        PERFORM CREATE_BDC_SESSIONS.
      MESSAGE I002 WITH 'Run the Report to check which orders have been
                                                                CREATED'.
      ELSEIF P_TABLE = 'X'.
       V_VIEW = 'A'.
    * Load Data from table.
        PERFORM F_TABLE_LOAD.
    * Create the BDC sessions.
        PERFORM CREATE_BDC_SESSIONS.
      MESSAGE I002 WITH 'Run the Report to check which orders have been
                                                                CREATED'.
      ELSEIF P_REPORT = 'X'.
    *Submit report.
       SUBMIT ZSDRLAPS AND RETURN
       USING SELECTION-SETS OF PROGRAM 'ZSDILAPT'
        WITH O_IHREZ IN O_IHREZ
        WITH O_VBELN IN O_VBELN
        WITH O_MESS IN O_MESS.
      ENDIF.
    * Archive the input file.
      IF ARC_FIL NE SPACE.
        PERFORM DEL_INP_FILE.
      ENDIF.
    IF V_MAIL = 1.
    MOVE 'CTRL F6 to Execute the LAPTOP Error log Program' TO I_MAIL-LINE.
    APPEND I_MAIL.
    CLEAR I_MAIL.
       CALL FUNCTION 'Z_SEND_MESSAGE'
            EXPORTING
                 MAIL_TO        = 'LAPTOPS'
                 MAIL_TITLE     = 'LAPTOP SALES ORDERS'
                 ATTACH_TYPE    = 'R'
                 NAME           = 'ZSDRLAPS'
            TABLES
                 CONTENTS       = I_MAIL
            EXCEPTIONS
                 PERS_NO_USERID = 1
                 OTHERS         = 2.
    ENDIF.
    END-OF-SELECTION.
    *        FORM CREATE_BDC_SESSION                                       *
    * This form will create a BDC session.                                 *
    FORM CREATE_BDC_SESSIONS.
      REFRESH BDCDATA.
      CLEAR   BDCDATA.
      OLD_RTYPE = SPACE.
      READ TABLE DATA_IN INDEX 1.
      OLD_RTYPE = DATA_IN-RTYPE.
      CLEAR DATA_IN.
      LOOP AT DATA_IN.
        IF OLD_RTYPE EQ '2' AND DATA_IN-RTYPE EQ '1'.
          PERFORM BDC_FIELD USING 'BDC_OKCODE'   '/11'.
          CALL TRANSACTION 'VA01' USING BDCDATA MODE V_VIEW UPDATE 'S'
                                                MESSAGES INTO MESSTAB.
    *  if sy-subrc ne 0.
          PERFORM F_MESSAGE_ANALYSIS.
    *  endif.
          REFRESH BDCDATA.
        ENDIF.
        IF DATA_IN-RTYPE = 1.
          PERFORM TRANS_VA01_HEADER.
        ELSE.
          PERFORM TRANS_VA01_ITEM.
        ENDIF.
        OLD_RTYPE = DATA_IN-RTYPE.
        MOVE-CORRESPONDING DATA_IN TO I_OUTPUT.
        APPEND I_OUTPUT.
        CLEAR I_OUTPUT.
      ENDLOOP.
      PERFORM BDC_FIELD USING 'BDC_OKCODE'   '/11'.
    * Call transaction
      CALL TRANSACTION 'VA01' USING BDCDATA MODE V_VIEW UPDATE 'S'
                                             MESSAGES INTO MESSTAB.
    *  if sy-subrc ne 0.
      PERFORM F_MESSAGE_ANALYSIS.
    *  endif.
      REFRESH BDCDATA.
    ENDFORM.
    *   FORM RANS_va01_header.                                            *
    *   Set up BDCDATA table for transaction VA01.                        *
    FORM TRANS_VA01_HEADER.
    * Process program SAPMV45a screen 0101
    * CREATE sales order Initial screen
      PERFORM BDC_NEW_DYNPRO USING 'SAPMV45A' '0101'.
      PERFORM BDC_FIELD USING 'VBAK-AUART'  DATA_IN-AUART.
      PERFORM BDC_FIELD USING 'VBAK-VKORG'  DATA_IN-VKORG.
      PERFORM BDC_FIELD USING 'VBAK-VTWEG'  DATA_IN-VTWEG.
      PERFORM BDC_FIELD USING 'VBAK-SPART'  DATA_IN-SPART.
    * perform bdc_field using 'VBAK-VKBUR'  data_in-vkbur.
    * perform bdc_field using 'VBAK-VKGRP'  data_in-vkgrp.
      PERFORM BDC_FIELD USING 'BDC_OKCODE'  '/0'.
    * Process program SAPMV45a screen 0402
      PERFORM BDC_NEW_DYNPRO USING 'SAPMV45A' '0402'.
    * Overview screen
      PERFORM BDC_FIELD USING 'KUAGV-KUNNR'  DATA_IN-KUNNR.
      PERFORM BDC_FIELD USING 'VBAK-BSTNK'  DATA_IN-BSTNK.
      PERFORM BDC_FIELD USING 'VBAK-BSTDK'  DATA_IN-BSTDK.
      PERFORM BDC_FIELD USING 'RV45A-KPRGBZ'  DATA_IN-KPRGBZ.
      PERFORM BDC_FIELD USING 'RV45A-KETDAT'  DATA_IN-KETDAT.
    * perform bdc_field using 'VBKD-PRSDT'  data_in-prsdt.
      PERFORM BDC_FIELD USING 'BDC_OKCODE'  'KKAU'.
    * Header Bus data
      PERFORM BDC_NEW_DYNPRO USING 'SAPMV45A' '0300'.
      PERFORM BDC_FIELD USING 'VBAK-LIFSK'  DATA_IN-LIFSK.
      PERFORM BDC_FIELD USING 'VBKD-INCO1'  DATA_IN-INCO1.
      PERFORM BDC_FIELD USING 'VBKD-INCO2'  DATA_IN-INCO1.
      PERFORM BDC_FIELD USING 'VBAK-FAKSK'  DATA_IN-FAKSK.
      PERFORM BDC_FIELD USING 'BDC_OKCODE'  'KPAR'.
    * Partner
      PERFORM BDC_NEW_DYNPRO USING 'SAPDV02P' '0624'.
      PERFORM BDC_FIELD USING 'RV02P-KUNDE(4)'  DATA_IN-KUNDE.
    * text
      IF DATA_IN-LTEXT1 NE SPACE.
        PERFORM CREATE_TEXT.
      ENDIF.
      PERFORM BDC_FIELD USING 'BDC_OKCODE'  'KBES'.
    * Purchase order data
      PERFORM BDC_NEW_DYNPRO USING 'SAPMV45A' '0351'.
      PERFORM BDC_FIELD USING 'VBAK-BSARK'  DATA_IN-BSARK.
      PERFORM BDC_FIELD USING 'VBAK-BNAME'  DATA_IN-BNAME.
      PERFORM BDC_FIELD USING 'VBAK-IHREZ'  DATA_IN-IHREZ.
      PERFORM BDC_FIELD USING 'BDC_OKCODE'  'UER1'.
    ENDFORM.
    *       FORM TRANS_VA01_ITEM                                          *
    FORM TRANS_VA01_ITEM.
      PERFORM BDC_NEW_DYNPRO USING 'SAPMV45A' '0402'.
      IF OLD_RTYPE = '1'.                  "ie, this is the first item.
        PERFORM BDC_FIELD USING 'VBAP-MATNR(001)' DATA_IN-MATNR.
        PERFORM BDC_FIELD USING 'RV45A-KWMENG(001)' DATA_IN-MENGE.
        PERFORM BDC_FIELD USING 'BDC_OKCODE' '/0'.
        PERFORM BDC_NEW_DYNPRO USING 'SAPMV45A' '0402'.
        PERFORM BDC_FIELD USING 'RV45A-VBAP_SELKZ(001)' 'X'.
        PERFORM BDC_FIELD USING 'BDC_OKCODE' 'PKAU'.
        PERFORM TRANS_VA01_ITEM_DETAILS.
      ELSE.
        PERFORM BDC_FIELD USING 'BDC_OKCODE' 'POAN'.       "create item
        PERFORM BDC_NEW_DYNPRO USING 'SAPMV45A' '0402'.
        PERFORM BDC_FIELD USING 'VBAP-MATNR(002)' DATA_IN-MATNR.
        IF DATA_IN-MENGE = SPACE.
          PERFORM BDC_FIELD USING 'RV45A-KWMENG(002)' DATA_IN-FREE_MENGE.
        ELSE.
          PERFORM BDC_FIELD USING 'RV45A-KWMENG(002)' DATA_IN-MENGE.
        ENDIF.
        PERFORM BDC_FIELD USING 'BDC_OKCODE' '/0'.
        PERFORM BDC_NEW_DYNPRO USING 'SAPMV45A' '0402'.
        PERFORM BDC_FIELD USING 'RV45A-VBAP_SELKZ(002)' 'X'.
        PERFORM BDC_FIELD USING 'BDC_OKCODE' 'PKAU'.
        PERFORM TRANS_VA01_ITEM_DETAILS.
      ENDIF.
    ENDFORM.
    *&      Form  TRANS_VA01_ITEM_DETAILS
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM TRANS_VA01_ITEM_DETAILS.
    *Business Data
      PERFORM BDC_NEW_DYNPRO USING 'SAPMV45A' '0450'.
      PERFORM BDC_FIELD USING 'VBAP-WERKS' DATA_IN-WERKS.
      IF DATA_IN-MENGE = SPACE.
        PERFORM BDC_FIELD USING 'VBAP-PSTYV' 'TANN'.
      ENDIF.
    *  perform bdc_field using 'VBAP-PSTYV' 'TAN'.
    * route mapping
      IF DATA_IN-ROUTE = 'D'.
        PERFORM BDC_FIELD USING 'VBAP-ROUTE' '000001'.
      ELSE.
      ENDIF.
      PERFORM BDC_FIELD USING 'VBAP-FAKSK' DATA_IN-FAKSK.
      PERFORM BDC_FIELD USING 'BDC_OKCODE'  'UER1'.
    ENDFORM.                               " TRANS_VA01_ITEM_DETAILS
    *       FORM BDC_NEW_DYNPRO                                           *
    *       Updates the BDCDATA table with the program and screen number  *
    *       of the next screen.                                           *
    FORM BDC_NEW_DYNPRO USING PROGRAM DYNPRO.
      CLEAR BDCDATA.
      BDCDATA-PROGRAM = PROGRAM.
      BDCDATA-DYNPRO  = DYNPRO.
      BDCDATA-DYNBEGIN = 'X'.
      APPEND BDCDATA.
    ENDFORM.
    *       FORM BDC_FIELD                                                *
    *       Updates the BDCDATA table with the field name and value of    *
    *       the current screen.                                           *
    *  -->  FIELD  -  Field name                                          *
    *  -->  VALUE  -  Field value                                         *
    FORM BDC_FIELD USING FIELD VALUE.
      IF VALUE NE SPACE.
        CLEAR BDCDATA.
        BDCDATA-FNAM = FIELD.
        BDCDATA-FVAL = VALUE.
        APPEND BDCDATA.
      ENDIF.
    ENDFORM.
    *&      Form  READ_FILE
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM READ_FILES.
    * Read order headers
      OPEN DATASET IDLH FOR INPUT IN TEXT MODE.
      IF SY-SUBRC NE 0.
        MESSAGE E002(ZZ) WITH 'Cannot find file in directory'.
      ENDIF.
      DO.
        READ DATASET IDLH INTO IDLORDH.
        IF SY-SUBRC NE 0.
          EXIT.
        ENDIF.
        APPEND IDLORDH.
      ENDDO.
      CLOSE DATASET IDLH.
    * Read order items
      OPEN DATASET IDLI FOR INPUT IN TEXT MODE.
      IF SY-SUBRC NE 0.
        MESSAGE E002(ZZ) WITH 'Cannot find file in directory'.
      ENDIF.
      DO.
        READ DATASET IDLI INTO IDLORDI.
        IF SY-SUBRC NE 0.
          EXIT.
        ENDIF.
        APPEND IDLORDI.
      ENDDO.
      CLOSE DATASET IDLI.
    ENDFORM.                               " READ_FILE_INTO_CUST
    *&      Form  DEL_INP_FILE
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM DEL_INP_FILE.
      DATA: PARAX(128).
      DATA: PARAM(200).
      DATA: CMDSTR(18),
            CMD_RESULT  LIKE BTCXPM OCCURS 10 WITH HEADER LINE,
            LINES TYPE I.
      DATA: PATH1(60) TYPE C.
      DATA: PATH2(60) TYPE C.
      DATA: NAME(20) TYPE C.
      DATA: INTNAME(20) TYPE C VALUE 'LAPTOP',
            V_FILENAME1(20) TYPE C VALUE 'ORDHT',
            V_FILENAME2(20) TYPE C VALUE 'ORDIT'.
      DATA: V_DATE LIKE SY-DATUM.
      V_DATE = SY-DATUM+4(4).
      CLEAR PARAX.
    * build IN directory
      PATH1 ='/'.
      WRITE SY-SYSID TO PATH1+1(3).        "D01 or T01 or P01 !
      WRITE 'INT/'    TO PATH1+4(4).       "Interfaces
      WRITE INTNAME TO PATH1+8(20).
      CONDENSE PATH1 NO-GAPS.
      WRITE '/IN' TO PATH1+30(5).
      CONDENSE PATH1 NO-GAPS.
    * build ARCH directory
      PATH2 ='/'.
      WRITE SY-SYSID TO PATH2+1(3).        "D01 or T01 or P01 !
      WRITE 'INT/'    TO PATH2+4(4).       "Interfaces
      WRITE INTNAME TO PATH2+8(20).
      CONDENSE PATH2 NO-GAPS.
      WRITE '/ARCH' TO PATH2+30(5).
      CONDENSE PATH2 NO-GAPS.
      DO 2 TIMES.
        CASE SY-INDEX.
          WHEN 1.
            IF IDLEX = 'X'.
              CONCATENATE 'IDL' V_FILENAME1 INTO NAME.
            ELSE.
              CONCATENATE 'DB' V_FILENAME1 INTO NAME.
            ENDIF.
    *   name = filename1.
          WHEN 2.
            IF IDLEX = 'X'.
              CONCATENATE 'IDL' V_FILENAME2 INTO NAME.
            ELSE.
              CONCATENATE 'DB'  V_FILENAME2 INTO NAME.
            ENDIF.
    *    name = filename2.
        ENDCASE.
        CMDSTR = 'ZMOV'.
        WRITE ' OBJ( TO PARAM.
        WRITE PATH1 TO PARAM+7(50).
        WRITE '/'   TO PARAM+50(1).
        CONDENSE PARAM NO-GAPS.
        WRITE NAME TO PARAM+70(12).
        CONDENSE PARAM NO-GAPS.
        WRITE )@TOOBJ( TO PARAM+70(13).
        CONDENSE PARAM NO-GAPS.
        WRITE PATH2 TO PARAM+82(60).
        CONDENSE PARAM NO-GAPS.
        WRITE '/'   TO PARAM+140(1).
        CONDENSE PARAM NO-GAPS.
        WRITE V_DATE TO PARAM+140(4).
        CONDENSE PARAM NO-GAPS.
        WRITE NAME TO PARAM+140(15).
        CONDENSE PARAM NO-GAPS.
        WRITE )' TO PARAM+142(5).
        CONDENSE PARAM NO-GAPS.
        REPLACE '@' WITH ' ' INTO PARAM.
    *  replace '@' with ' ' into param.
        MOVE PARAM(127) TO PARAX(127).
        CALL FUNCTION 'SXPG_CALL_SYSTEM'
             EXPORTING
                  COMMANDNAME       = CMDSTR
                  PARAMETERS        = PARAX
             TABLES
                  EXEC_PROTOCOL     = CMD_RESULT
             EXCEPTIONS
                  NO_PERMISSION     = 1
                  COMMAND_NOT_FOUND = 2
                  OTHERS            = 4.
        IF SY-SUBRC <> 0.                  "extenal command not executed
        MESSAGE I002 WITH 'error calling external command - call sys admin'.
        ENDIF.
      ENDDO.
    ENDFORM.                               " DEL_INP_FILE
    *&      Form  CREATE_TEXT
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM CREATE_TEXT.
      PERFORM BDC_FIELD USING 'BDC_OKCODE'  'KTEX'.
    * Text overview
      PERFORM BDC_NEW_DYNPRO USING 'SAPMV45A' '0150'.
      PERFORM BDC_FIELD USING 'RTEXT-SELKZ(02)' 'X'.
      PERFORM BDC_FIELD USING 'RTEXT-SPRAS(02)' 'E'.
      PERFORM BDC_FIELD USING 'BDC_OKCODE'  'TEDE'.
    * Text editor
      PERFORM BDC_NEW_DYNPRO USING 'SAPLSTXX' '1100'.
      PERFORM BDC_FIELD USING 'BDC_OKCODE'  '/06'.
      PERFORM BDC_NEW_DYNPRO USING 'SAPLSTXX' '1100'.
      PERFORM BDC_FIELD USING 'BDC_CURSOR' 'RSTXT-TXLINE(02)'.
      PERFORM BDC_FIELD USING 'RSTXT-TXLINE(02)' DATA_IN-LTEXT2(70).
      PERFORM BDC_FIELD USING 'BDC_OKCODE'  '/06'.
      PERFORM BDC_NEW_DYNPRO USING 'SAPLSTXX' '1100'.
      PERFORM BDC_FIELD USING 'BDC_CURSOR' 'RSTXT-TXLINE(02)'.
      PERFORM BDC_FIELD USING 'RSTXT-TXLINE(02)' DATA_IN-LTEXT1(70).
      PERFORM BDC_FIELD USING 'BDC_CURSOR' 'RSTXT-TXLINE(04)'.
    * perform bdc_field using 'BDC_OKCODE'  '/06'.
    * perform bdc_new_dynpro using 'SAPLSTXX' '1100'.
    *  PERFORM BDC_FIELD USING 'RSTXT-TXLINE(004)' DATA_IN-ltext+140(70).
    *  PERFORM BDC_FIELD USING 'BDC_OKCODE'  '/06'.
    *  PERFORM BDC_NEW_DYNPRO USING 'SAPLSTXX' '1100'.
    *  PERFORM BDC_FIELD USING 'RSTXT-TXLINE(005)' DATA_IN-ltext+210(46).
    *  PERFORM BDC_FIELD USING 'BDC_OKCODE'  '/06'.
      PERFORM BDC_NEW_DYNPRO USING 'SAPLSTXX' '1100'.
      PERFORM BDC_FIELD USING 'BDC_OKCODE'  'TXVB'.
      PERFORM BDC_NEW_DYNPRO USING 'SAPLSTXX' '1100'.
      PERFORM BDC_FIELD USING 'BDC_OKCODE'  'TXEX'.
      PERFORM BDC_NEW_DYNPRO USING 'SAPMV45A' '0150'.
    ENDFORM.                               " CREATE_TEXT
    *&      Form  MAP_DATA
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM MAP_DATA.
      TABLES: KNB1, CABN, AUSP.
      TABLES: ZPM1.
      DATA: V_CUST_NO(11) TYPE C.
      CLEAR IDLORDH.
      CLEAR DATA_IN.
      SELECT * FROM CABN
            WHERE ATNAM = 'ORDER_ENTRY_CODE'.
        EXIT.
      ENDSELECT.
      SELECT OBJEK ATWRT INTO (I_MATERIAL-MATNR, I_MATERIAL-ORDER)
            FROM AUSP
            WHERE ATINN = CABN-ATINN.
      APPEND I_MATERIAL.
    ENDSELECT.
    LOOP AT IDLORDH.
      MOVE '1' TO DATA_IN-RTYPE.
    * Order type.
      DATA_IN-AUART = 'ZOR'.
    * Sales organisation
      IF IDLEX EQ 'X'.
        DATA_IN-VKORG = '1100'.            "idl domestic.
      ELSE.
        DATA_IN-VKORG = '1350'.            "dillion bass domestic.
      ENDIF.
    * Distribution Channel
      DATA_IN-VTWEG = '10'.
    * Division
      DATA_IN-SPART = '10'.
    * Customer Number
      IF IDLORDH-CUST-NO(1) = SPACE.
        CONCATENATE '0' IDLORDH-CUST-NO INTO V_CUST_NO.
        CONDENSE V_CUST_NO NO-GAPS.
      ELSE.
        V_CUST_NO = IDLORDH-CUST-NO.
      ENDIF.
      DO 4 TIMES.
        IF IDLORDH-BRANCH-NO CS SPACE.
          REPLACE SPACE WITH '0' INTO IDLORDH-BRANCH-NO.
        ENDIF.
      ENDDO.
      move idlordh-branch-no to v_cust_no+7(4).
      select * from knb1 where eikto = v_cust_no.
        EXIT.
      ENDSELECT.
      MOVE KNB1-KUNNR TO DATA_IN-KUNNR.
    * Sales Office
    *ata_in-vkbur.
    * Sales Group
    *ata_in-vkgrp
    * PO number
      DATA_IN-BSTNK = IDLORDH-CUST-ORDER-NO.
    * PO ref number
      IF IDLORDH-IDL-ORDER-NO(1) EQ SPACE.
        MOVE IDLORDH-IDL-ORDER-NO TO V_IDL-ORDER-NO.
        REPLACE SPACE WITH '0' INTO V_IDL-ORDER-NO.
      ENDIF.
      MOVE IDLORDH-PC-USER-NO TO V_PC-USER-NO.
      DO 3 TIMES.
        REPLACE SPACE WITH '0' INTO V_PC-USER-NO.
      ENDDO.
      CONCATENATE V_IDL-ORDER-NO '-' V_PC-USER-NO INTO V_IHREZ.
      DATA_IN-IHREZ = V_IHREZ.
    * PO Date
      DATA_IN-BSTDK = IDLORDH-PC-ORDER-DATE.
      DO 2 TIMES.
        REPLACE '/' WITH '.' INTO IDLORDH-PC-ORDER-DATE.
      ENDDO.
      DATA_IN-BSTDK = IDLORDH-PC-ORDER-DATE.
    * Date Type
    *ata_in-kprgbz
    * Required Delivery Date
      DO 2 TIMES.
        REPLACE '/' WITH '.' INTO IDLORDH-PC-DATE-REQD.
      ENDDO.
      DATA_IN-KETDAT = IDLORDH-PC-DATE-REQD.
    *pricing date
    *ata_in-prsdt
    *delivery block
    *ata_in-lifsk
    *inco terms.
      IF IDLORDH-FOR-COLLECTION = 'Y'.
        DATA_IN-INCO1 = 'EXW'.
      ELSE.
        DATA_IN-INCO1 = 'CIF'.
      ENDIF.
    *inco description
    *ata_in-inco2
    *billing block
      IF IDLORDH-HOLD-FOR-PRICING = 'Y'.
        DATA_IN-FAKSK = '99'.
      ENDIF.
    *shipto
    *ata_in-kunde
    *special text
      DATA_IN-LTEXT1 = IDLORDH-SPEC-INS-1.
      DATA_IN-LTEXT2 = IDLORDH-SPEC-INS-2.
    *ordering method
      DATA_IN-BSARK = 'LAPT'.
    *plant.
      SELECT * FROM ZPM1
         WHERE ZLPLANT = IDLORDH-SITE-PREFIX.
        EXIT.
      ENDSELECT.
      DATA_IN-WERKS = ZPM1-ZWERKS.
    *orderer
    *data_in-bname
      APPEND DATA_IN.
      CLEAR DATA_IN.
      LOOP AT IDLORDI WHERE IDL-ORDER-NO = IDLORDH-IDL-ORDER-NO AND
                            PC-USER-NO = IDLORDH-PC-USER-NO.
        MOVE '2' TO DATA_IN-RTYPE.
    *item
    *material no.
        READ TABLE I_MATERIAL WITH KEY ORDER = IDLORDI-ORDER-ENTRY-CODE.
        DATA_IN-MATNR = I_MATERIAL-MATNR.
    *Order quantity
        DATA_IN-MENGE = IDLORDI-QTY-TO-ORDER.
        DATA_IN-FREE_MENGE = IDLORDI-FREE-QTY-ORDERED.
    *plant.
        DATA_IN-WERKS = ZPM1-ZWERKS.
    *ata_in-pstyv
    *       route
    *       vrkme
    *       itext
        APPEND DATA_IN.
        IF  IDLORDI-FREE-QTY-ORDERED > 0.
          CLEAR DATA_IN-MENGE.
          APPEND DATA_IN.
        ENDIF.
        CLEAR DATA_IN.
      ENDLOOP.
    ENDLOOP.
    ENDFORM.                               " MAP_DATA
    *&      Form  F_MESSAGE_ANALYSIS
    *  <--  p2        text
    FORM F_MESSAGE_ANALYSIS.
      DATA: V_FIRST(1) TYPE C VALUE '1',
            V_COUNT(2) TYPE N,
            V_MESSAGE(1) TYPE C,
            V_MESSLINES(2) TYPE N.
      CLEAR: V_IHREZ, V_MESSLINES.
      DESCRIBE TABLE MESSTAB LINES V_MESSLINES.
      READ TABLE MESSTAB WITH KEY MSGTYP = 'S' MSGID = 'V1' MSGNR = '311'.
      IF SY-SUBRC = 0.
        IF V_MESSLINES = 1.
          V_MESSAGE = 'S'.
        ELSE.
          V_MESSAGE = 'W'.
          V_MAIL = 1.
        ENDIF.
        V_VBELN = MESSTAB-MSGV2(08).
      ELSE.
        V_MESSAGE = 'E'.
        V_MAIL = 1.
      ENDIF.
      V_FIRST = 1.
      LOOP AT I_OUTPUT.
        IF V_FIRST = 1.
          MOVE I_OUTPUT-IHREZ TO V_IHREZ.
          CLEAR V_FIRST.
        ENDIF.
        ZSOM1-VBELN = V_VBELN.
        ZSOM1-ITEM_NO = V_ITEM_NO.
        ZSOM1-MESS = V_MESSAGE.
        MOVE-CORRESPONDING I_OUTPUT TO ZSOM1.
        ZSOM1-IHREZ = V_IHREZ.
        MODIFY ZSOM1.
        CLEAR ZSOM1.
        V_ITEM_NO = V_ITEM_NO + 1.
      ENDLOOP.
      LOOP AT MESSTAB.
        V_COUNT = V_COUNT + 1.
        ZSOM2-MCOUNT = V_COUNT.
        ZSOM2-IHREZ = V_IHREZ.
        CASE MESSTAB-MSGTYP.
          WHEN 'E'.
            MOVE-CORRESPONDING MESSTAB TO ZSOM2.
          WHEN 'A'.
            MOVE-CORRESPONDING MESSTAB TO ZSOM2.
          WHEN 'W'.
            MOVE V_VBELN TO ZSOM2-VBELN.
            MOVE-CORRESPONDING MESSTAB TO ZSOM2.
          WHEN 'I'.
            MOVE V_VBELN TO ZSOM2-VBELN.
            MOVE-CORRESPONDING MESSTAB TO ZSOM2.
          WHEN 'S'.
            MOVE V_VBELN TO ZSOM2-VBELN.
            MOVE-CORRESPONDING MESSTAB TO ZSOM2.
        ENDCASE.
        MODIFY ZSOM2.
        CLEAR ZSOM2.
      ENDLOOP.
      REFRESH: MESSTAB, I_OUTPUT.
      CLEAR: MESSTAB, I_OUTPUT.
      CLEAR: V_FIRST, V_VBELN, V_IHREZ, V_ITEM_NO, V_COUNT, V_MESSAGE.
    ENDFORM.                               " F_MESSAGE_ANALYSIS
    *&      Form  F_TABLE_LOAD
    FORM F_TABLE_LOAD.
      SELECT * FROM ZSOM1
       WHERE IHREZ IN O_IHREZ
         AND MESS = 'E'.
        IF NOT ZSOM1-VBELN IS INITIAL.
          CHECK ZSOM1-VBELN IN O_VBELN.
        ENDIF.
        MOVE-CORRESPONDING ZSOM1 TO DATA_IN.
        APPEND DATA_IN.
        CLEAR DATA_IN.
      ENDSELECT.
    ENDFORM.                               " F_TABLE_LOAD

  • Problem in BDC for VA01

    Dear Experts,
    I have developed a BDC Program for transaction VA01, if there is change in price it shows warning message as 'Condition PR00 has been changed' and loose the control, at that time if click on enter it will regain the control and proceed further.
    I have added an extra code for 'enter' but its not working, please share your ideas to fix this issue.
    thanks in advance...
    Venkat

    Hi Madhukar,
    thanks for writing.
    yes when I execute program in forground it shows warning message and looses the control.
    If execute in background it will not create SO at all.
    I tried to do recording for this case again but even while recording also it looses the control when I press enter then it will regain the control but that wont recorded.
    Regards,
    Venkat

Maybe you are looking for