BDC for ME21 Po create

Hi ALL,
Iam Creating BDC Program bu using ME21 for Uploading PO.
Iam getting error at Income term2 in the Second Screen of ME21. Iam Passing this value through Excel Sheet But event then it is not picking. When i check in debugging the value of income term2 is populating.
Let me know what are the mandotory fields for creating PO using Me21.
Here iam also attaching the code, Please help us because it is very urgent.
report ZPOUPLOADME21
no standard page heading line-size 255.
*include bdcrecx1.
INCLUDE YMM_BDCRECX1.
•     Internal Table T_BDCDATA to store BDC data
•     Batchinputdata of single transaction
DATA: T_BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
•     Internal Table T_BDC_MSG to store BDC messages
DATA: T_BDC_MSG LIKE STANDARD TABLE OF BDCMSGCOLL INITIAL
SIZE 0 WITH HEADER LINE.
DATA: V_FILE LIKE RLGRAP-FILENAME ,
V_COUNT(5) TYPE C,
V_MESSAGE_CNT(5) TYPE C .
DATA : BEGIN OF IT_DATA OCCURS 0,
LIFNR LIKE EKKO-LIFNR, " Vendor
BSART LIKE RM06E-BSART, " Order Type
BEDAT(10) TYPE C, " Date
EKORG LIKE EKKO-EKORG, " Purchasing Organization
EKGRP LIKE EKKO-EKGRP, " Purchasing Group
WERKS LIKE RM06E-WERKS, " Plant
INCO2 LIKE EKKO-INCO2, " Inco Terms
KNTTP LIKE EKPO-KNTTP, " A/C Assignment Category
EMATN LIKE EKPO-EMATN, " Material Number
MENGE LIKE EKPO-MENGE, " Purchase Order Quantity
NETPR LIKE EKPO-NETPR, " Net Price
MWSKZ LIKE EKPO-MWSKZ, " Tax Code
NPLNR LIKE MSEG-NPLNR, " Network
VORNR LIKE PSORDER-VORNR, " Operation
END OF IT_DATA.
START-OF-SELECTION.
PERFORM OPEN_GROUP.
PERFORM DATA_UPLOAD.
PERFORM CALL_TRANSACTION.
PERFORM CLOSE_GROUP.
PERFORM WRITE_ERROR.
*& Form DATA_UPLOAD
•     text
•     --> p1 text
•     <-- p2 text
FORM DATA_UPLOAD.
*call function ws_upload to retrieve data from a flat file in the
*presentation server into an internal table
CALL FUNCTION 'UPLOAD'
EXPORTING
FILENAME = V_FILE
FILETYPE = 'DAT'
TABLES
DATA_TAB = IT_DATA
EXCEPTIONS
CONVERSION_ERROR = 1
INVALID_TABLE_WIDTH = 2
INVALID_TYPE = 3
NO_BATCH = 4
UNKNOWN_ERROR = 5
GUI_REFUSE_FILETRANSFER = 6
OTHERS = 7.
•     if ws_upload fails then display appropriate message
IF SY-SUBRC 0.
•     MESSAGE E000 WITH 'Data not Uploaded into internal table'.
ENDIF.
ENDFORM. " DATA_UPLOAD
*& Form CALL_TRANSACTION
•     text
•     --> p1 text
•     <-- p2 text
FORM CALL_TRANSACTION.
DATA : V_IVDAT(10) TYPE C,
V_AKTIV(10) TYPE C,
V_MESSAGE(404) TYPE C.
REFRESH T_BDCDATA.
CLEAR T_BDCDATA.
V_COUNT = 0.
V_MESSAGE_CNT = 0.
LOOP AT IT_DATA .
V_COUNT = V_COUNT + 1.
*perform open_group.
perform bdc_dynpro using 'SAPMM06E' '0100'.
perform bdc_field using 'BDC_CURSOR'
'RM06E-WERKS'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'EKKO-LIFNR'
IT_DATA-LIFNR.
perform bdc_field using 'RM06E-BSART'
IT_DATA-BSART.
*perform bdc_field using 'RM06E-BEDAT'
•     '24.01.2008'.
perform bdc_field using 'RM06E-BEDAT'
IT_DATA-BEDAT.
perform bdc_field using 'EKKO-EKORG'
IT_DATA-EKORG.
perform bdc_field using 'EKKO-EKGRP'
IT_DATA-EKGRP.
*perform bdc_field using 'RM06E-LPEIN'
•     'T'.
perform bdc_field using 'RM06E-WERKS'
IT_DATA-WERKS.
perform bdc_dynpro using 'SAPMM06E' '0101'.
perform bdc_field using 'BDC_CURSOR'
'EKKO-INCO2'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
*perform bdc_field using 'EKKO-EKGRP'
•     IT_DATA-EKGRP1. "'SP3'.
*perform bdc_field using 'EKKO-PINCR'
•     IT_DATA-PINCR. "'10'.
*perform bdc_field using 'EKKO-SPRAS'
•     IT_DATA-SPRAS. "'EN'.
*perform bdc_field using 'EKKO-UPINC'
•     IT_DATA-UPINC. "'1'.
*perform bdc_field using 'EKKO-ZTERM'
•     IT_DATA-ZTERM.
*perform bdc_field using 'EKKO-WAERS'
•     IT_DATA-WAERS. "'INR'.
*perform bdc_field using 'EKKO-ZBD1T'
•     IT_DATA-ZBD1T. "'44'.
*perform bdc_field using 'EKKO-WKURS'
•     IT_DATA-WKURS. "' 1.00000'.
*perform bdc_field using 'EKKO-INCO1'
•     IT_DATA-INCO1.
perform bdc_field using 'EKKO-INCO2'
IT_DATA-INCO2.
perform bdc_dynpro using 'SAPMM06E' '0120'.
perform bdc_field using 'BDC_CURSOR'
'EKPO-NETPR(01)'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
*perform bdc_field using 'EKPO-KNTTP(01)'
•     'N'.
perform bdc_field using 'EKPO-KNTTP(01)'
IT_DATA-KNTTP.
perform bdc_field using 'EKPO-EMATN(01)'
IT_DATA-EMATN.
perform bdc_field using 'EKPO-MENGE(01)'
IT_DATA-MENGE.
perform bdc_field using 'EKPO-NETPR(01)'
IT_DATA-NETPR.
perform bdc_dynpro using 'SAPMM06E' '0111'.
perform bdc_field using 'BDC_CURSOR'
'EKPO-MWSKZ'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
*perform bdc_field using 'EKPO-KNTTP'
•     'N'.
*perform bdc_field using 'EKPO-TXZ01'
•     'Clamps & Connector'.
*perform bdc_field using 'EKPO-MENGE'
•     '4'.
*perform bdc_field using 'EKPO-SPINF'
•     'A'.
*perform bdc_field using 'EKPO-NETPR'
•     '100.00'.
*perform bdc_field using 'EKPO-PEINH'
•     '1'.
*perform bdc_field using 'EKPO-BPRME'
•     'NO'.
*perform bdc_field using 'EKPO-BPUMN'
•     '1'.
*perform bdc_field using 'EKPO-BPUMZ'
•     '1'.
*perform bdc_field using 'EKPO-PRSDR'
•     'X'.
*perform bdc_field using 'RM06E-EEIND'
•     '24.01.2008'.
*perform bdc_field using 'RM06E-LPEIN'
•     'D'.
*perform bdc_field using 'EKPO-WEPOS'
•     'X'.
perform bdc_field using 'EKPO-MWSKZ'
IT_DATA-MWSKZ.
*perform bdc_field using 'EKPO-REPOS'
•     'X'.
perform bdc_dynpro using 'SAPMM06E' '0511'.
perform bdc_field using 'BDC_CURSOR'
'EKKN-SAKTO'.
perform bdc_field using 'BDC_OKCODE'
'=ENTE'.
*perform bdc_field using 'EKKN-SAKTO'
•     '6034025'.
*perform bdc_field using 'DKACB-FMORE'
•     'X'.
perform bdc_dynpro using 'SAPLKACB' '0002'.
*perform bdc_field using 'BDC_CURSOR'
•     'COBL-VORNR'.
perform bdc_field using 'BDC_OKCODE'
'=ENTE'.
perform bdc_field using 'COBL-NPLNR'
IT_DATA-NPLNR.
perform bdc_field using 'COBL-VORNR'
IT_DATA-VORNR.
perform bdc_dynpro using 'SAPMM06E' '0111'.
perform bdc_dynpro using 'SAPMM06E' '0120'.
perform bdc_field using 'BDC_CURSOR'
'RM06E-EBELP'.
perform bdc_field using 'BDC_OKCODE'
'=BU'.
*perform bdc_field using 'RM06E-EBELP'
•     '10'.
perform bdc_dynpro using 'SAPLSPO1' '0300'.
perform bdc_field using 'BDC_OKCODE'
'=YES'.
perform bdc_transaction using 'ME21'.
perform close_group.
LOOP AT T_MESSTAB WHERE REC_NO IS INITIAL.
AT FIRST.
V_MESSAGE_CNT = V_MESSAGE_CNT + 1.
T_MESSTAB-REC_NO = V_COUNT.
ENDAT.
MODIFY T_MESSTAB TRANSPORTING REC_NO.
ENDLOOP.
REFRESH T_BDCDATA.
CLEAR T_BDCDATA.
ENDLOOP.
SKIP.
WRITE : /10 'Record Number ', 30 'Error Message'.
SKIP.
endform.
*& Form WRITE_ERROR
•     text
•     --> p1 text
•     <-- p2 text
FORM WRITE_ERROR.
LOOP AT T_MESSTAB.
WRITE : /10 T_MESSTAB-REC_NO , 30 T_MESSTAB-MESSAGE.
ENDLOOP.
ULINE /10(100).
WRITE : /10 'No of Records : ' , V_COUNT.
WRITE : /10 'No of Erroneous Records : ' , V_MESSAGE_CNT.
ULINE /10(100).
ENDFORM. " WRITE_ERROR
*& Form CHECK_BDC
•     text
•     --> p1 text
•     <-- p2 text
FORM CHECK_BDC.
DATA: L_CHECK LIKE YMMT_CHECK_BDC-YCHECK.
SELECT SINGLE YCHECK INTO L_CHECK FROM YMMT_CHECK_BDC
WHERE PROGRAMM EQ SY-REPID
AND YCHECK EQ 'X'.
IF SY-SUBRC NE 0.
MESSAGE S000(YM) WITH 'Execution not possible'.
STOP.
ENDIF.
ENDFORM. " CHECK_BDC
<REMOVED BY MODERATOR>
Thanks
Rahul
Edited by: Alvaro Tejada Galindo on Jan 24, 2008 9:38 AM

it depends on your release whether you can use ME21N and/or the bapi.
but why throw away what you have already achieved? ME21 still works also in later releases. to find out the mandatory fields in your system, check the customzing settings in tx. OLME -> Purchase Order -> Define Screen Layout at Document Level -> click on ME21 -> Terms of delivery and payment. Here are the incoterm-settings.
Edited by: Mylene Euridice Dorias on Jan 24, 2008 5:19 PM

Similar Messages

  • BAPI_GOODSMVT_CREATE or BDC for MB1A not creating Accounting Doc

    It is a strange scenario.  We can manually process a Goods Issue (without reference to a PO# - WBS Element used instead) via MB1A and have an Accounting Doc generated without a problem - movememt 415Q.  But for some reason, we can only create the Material Doc for Goods Issue when using BAPI_GOODSMVT_CREATE or BDC for MB1A (foreground or background).
    Does anyone have any idea why in the world this would be happening?  Especially if we're using the exact same data used to manually create the Goods Issue via MB1A?

    Thanks for the response.  Yes, I did try BAPI_TRANSACTION_COMMIT in all of my tests.  The Accounting Document simply will not get generated.
    Again, what makes it strange is that we created a BDC for MB1A - based on data that worked & that produced an Accounting document.  However, when processing that BDC, either in the foreground or background - the Accounting document likewise does not get created.

  • BDC FOR ME21

    Hi ALL,
    Iam Creating BDC Program bu using ME21 for Uploading PO.
    Iam getting error at Income term2 in the Second Screen of ME21. Iam Passing this value through Excel Sheet But event then it is not picking. When i check in debugging the value of income term2 is populating.
    Let me know what are the mandotory fields for creating PO using Me21.
    Here iam also attaching the code, Please help us because it is very urgent.
    report ZPOUPLOADME21
           no standard page heading line-size 255.
    *include bdcrecx1.
    INCLUDE YMM_BDCRECX1.
    Internal Table T_BDCDATA to store BDC data
           Batchinputdata of single transaction
    DATA:   T_BDCDATA LIKE BDCDATA  OCCURS 0 WITH HEADER LINE.
    Internal Table T_BDC_MSG to store BDC messages
    DATA:   T_BDC_MSG LIKE STANDARD TABLE OF BDCMSGCOLL INITIAL
            SIZE 0 WITH HEADER LINE.
    DATA:   V_FILE LIKE RLGRAP-FILENAME ,
            V_COUNT(5) TYPE C,
            V_MESSAGE_CNT(5) TYPE C .
    DATA : BEGIN OF IT_DATA OCCURS 0,
           LIFNR LIKE EKKO-LIFNR,      " Vendor
           BSART LIKE RM06E-BSART,     " Order Type
           BEDAT(10) TYPE C,           " Date
           EKORG LIKE EKKO-EKORG,      " Purchasing Organization
           EKGRP LIKE EKKO-EKGRP,      " Purchasing Group
           WERKS LIKE RM06E-WERKS,     " Plant
           INCO2 LIKE EKKO-INCO2,      " Inco Terms
           KNTTP LIKE EKPO-KNTTP,      " A/C Assignment Category
           EMATN LIKE EKPO-EMATN,      " Material Number
           MENGE LIKE EKPO-MENGE,      " Purchase Order Quantity
           NETPR LIKE EKPO-NETPR,      " Net Price
           MWSKZ LIKE EKPO-MWSKZ,      " Tax Code
           NPLNR LIKE MSEG-NPLNR,      " Network
           VORNR LIKE PSORDER-VORNR,   " Operation
           END OF IT_DATA.
    START-OF-SELECTION.
         PERFORM OPEN_GROUP.
         PERFORM DATA_UPLOAD.
         PERFORM CALL_TRANSACTION.
         PERFORM CLOSE_GROUP.
         PERFORM WRITE_ERROR.
    *&      Form  DATA_UPLOAD
          text
    -->  p1        text
    <--  p2        text
    FORM DATA_UPLOAD.
    *call function ws_upload to retrieve data from a flat file in the
    *presentation server into an internal table
      CALL FUNCTION 'UPLOAD'
           EXPORTING
                FILENAME                = V_FILE
                FILETYPE                = 'DAT'
           TABLES
                DATA_TAB                = IT_DATA
           EXCEPTIONS
                CONVERSION_ERROR        = 1
                INVALID_TABLE_WIDTH     = 2
                INVALID_TYPE            = 3
                NO_BATCH                = 4
                UNKNOWN_ERROR           = 5
                GUI_REFUSE_FILETRANSFER = 6
                OTHERS                  = 7.
    if ws_upload fails then display appropriate message
      IF SY-SUBRC <> 0.
       MESSAGE E000  WITH 'Data not Uploaded into internal table'.
      ENDIF.
    ENDFORM.                    " DATA_UPLOAD
    *&      Form  CALL_TRANSACTION
          text
    -->  p1        text
    <--  p2        text
    FORM CALL_TRANSACTION.
      DATA : V_IVDAT(10) TYPE C,
             V_AKTIV(10) TYPE  C,
             V_MESSAGE(404) TYPE C.
      REFRESH T_BDCDATA.
      CLEAR T_BDCDATA.
      V_COUNT = 0.
      V_MESSAGE_CNT = 0.
      LOOP AT IT_DATA .
        V_COUNT = V_COUNT + 1.
    *perform open_group.
    perform bdc_dynpro      using 'SAPMM06E' '0100'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'RM06E-WERKS'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'EKKO-LIFNR'
                                  IT_DATA-LIFNR.
    perform bdc_field       using 'RM06E-BSART'
                                  IT_DATA-BSART.
    *perform bdc_field       using 'RM06E-BEDAT'
                                 '24.01.2008'.
    perform bdc_field       using 'RM06E-BEDAT'
                                  IT_DATA-BEDAT.
    perform bdc_field       using 'EKKO-EKORG'
                                  IT_DATA-EKORG.
    perform bdc_field       using 'EKKO-EKGRP'
                                  IT_DATA-EKGRP.
    *perform bdc_field       using 'RM06E-LPEIN'
                                 'T'.
    perform bdc_field       using 'RM06E-WERKS'
                                  IT_DATA-WERKS.
    perform bdc_dynpro      using 'SAPMM06E' '0101'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'EKKO-INCO2'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    *perform bdc_field       using 'EKKO-EKGRP'
                                 IT_DATA-EKGRP1. "'SP3'.
    *perform bdc_field       using 'EKKO-PINCR'
                                 IT_DATA-PINCR. "'10'.
    *perform bdc_field       using 'EKKO-SPRAS'
                                 IT_DATA-SPRAS. "'EN'.
    *perform bdc_field       using 'EKKO-UPINC'
                                 IT_DATA-UPINC. "'1'.
    *perform bdc_field       using 'EKKO-ZTERM'
                                 IT_DATA-ZTERM.
    *perform bdc_field       using 'EKKO-WAERS'
                                 IT_DATA-WAERS. "'INR'.
    *perform bdc_field       using 'EKKO-ZBD1T'
                                 IT_DATA-ZBD1T. "'44'.
    *perform bdc_field       using 'EKKO-WKURS'
                                 IT_DATA-WKURS. "' 1.00000'.
    *perform bdc_field       using 'EKKO-INCO1'
                                 IT_DATA-INCO1.
    perform bdc_field       using 'EKKO-INCO2'
                                  IT_DATA-INCO2.
    perform bdc_dynpro      using 'SAPMM06E' '0120'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'EKPO-NETPR(01)'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    *perform bdc_field       using 'EKPO-KNTTP(01)'
                                 'N'.
    perform bdc_field       using 'EKPO-KNTTP(01)'
                                  IT_DATA-KNTTP.
    perform bdc_field       using 'EKPO-EMATN(01)'
                                  IT_DATA-EMATN.
    perform bdc_field       using 'EKPO-MENGE(01)'
                                  IT_DATA-MENGE.
    perform bdc_field       using 'EKPO-NETPR(01)'
                                  IT_DATA-NETPR.
    perform bdc_dynpro      using 'SAPMM06E' '0111'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'EKPO-MWSKZ'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    *perform bdc_field       using 'EKPO-KNTTP'
                                 'N'.
    *perform bdc_field       using 'EKPO-TXZ01'
                                 'Clamps & Connector'.
    *perform bdc_field       using 'EKPO-MENGE'
                                 '4'.
    *perform bdc_field       using 'EKPO-SPINF'
                                 'A'.
    *perform bdc_field       using 'EKPO-NETPR'
                                 '100.00'.
    *perform bdc_field       using 'EKPO-PEINH'
                                 '1'.
    *perform bdc_field       using 'EKPO-BPRME'
                                 'NO'.
    *perform bdc_field       using 'EKPO-BPUMN'
                                 '1'.
    *perform bdc_field       using 'EKPO-BPUMZ'
                                 '1'.
    *perform bdc_field       using 'EKPO-PRSDR'
                                 'X'.
    *perform bdc_field       using 'RM06E-EEIND'
                                 '24.01.2008'.
    *perform bdc_field       using 'RM06E-LPEIN'
                                 'D'.
    *perform bdc_field       using 'EKPO-WEPOS'
                                 'X'.
    perform bdc_field       using 'EKPO-MWSKZ'
                                  IT_DATA-MWSKZ.
    *perform bdc_field       using 'EKPO-REPOS'
                                 'X'.
    perform bdc_dynpro      using 'SAPMM06E' '0511'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'EKKN-SAKTO'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=ENTE'.
    *perform bdc_field       using 'EKKN-SAKTO'
                                 '6034025'.
    *perform bdc_field       using 'DKACB-FMORE'
                                 'X'.
    perform bdc_dynpro      using 'SAPLKACB' '0002'.
    *perform bdc_field       using 'BDC_CURSOR'
                                 'COBL-VORNR'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=ENTE'.
    perform bdc_field       using 'COBL-NPLNR'
                                  IT_DATA-NPLNR.
    perform bdc_field       using 'COBL-VORNR'
                                  IT_DATA-VORNR.
    perform bdc_dynpro      using 'SAPMM06E' '0111'.
    perform bdc_dynpro      using 'SAPMM06E' '0120'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'RM06E-EBELP'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=BU'.
    *perform bdc_field       using 'RM06E-EBELP'
                                 '10'.
    perform bdc_dynpro      using 'SAPLSPO1' '0300'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=YES'.
    perform bdc_transaction using 'ME21'.
    perform close_group.
    LOOP AT T_MESSTAB WHERE REC_NO IS INITIAL.
        AT FIRST.
          V_MESSAGE_CNT = V_MESSAGE_CNT + 1.
          T_MESSTAB-REC_NO = V_COUNT.
        ENDAT.
          MODIFY T_MESSTAB TRANSPORTING REC_NO.
        ENDLOOP.
        REFRESH T_BDCDATA.
        CLEAR T_BDCDATA.
    ENDLOOP.
      SKIP.
      WRITE : /10 'Record Number ', 30 'Error Message'.
      SKIP.
    endform.
    *&      Form  WRITE_ERROR
          text
    -->  p1        text
    <--  p2        text
    FORM WRITE_ERROR.
      LOOP AT T_MESSTAB.
        WRITE : /10 T_MESSTAB-REC_NO , 30 T_MESSTAB-MESSAGE.
      ENDLOOP.
      ULINE /10(100).
      WRITE : /10 'No of Records : ' , V_COUNT.
      WRITE : /10 'No of Erroneous Records : ' , V_MESSAGE_CNT.
      ULINE /10(100).
    ENDFORM.                    " WRITE_ERROR
    *&      Form  CHECK_BDC
          text
    -->  p1        text
    <--  p2        text
    FORM CHECK_BDC.
    DATA: L_CHECK LIKE YMMT_CHECK_BDC-YCHECK.
      SELECT SINGLE YCHECK INTO L_CHECK FROM YMMT_CHECK_BDC
                                         WHERE PROGRAMM EQ SY-REPID
                                           AND YCHECK EQ 'X'.
      IF SY-SUBRC NE 0.
        MESSAGE S000(YM) WITH 'Execution not possible'.
        STOP.
      ENDIF.
    ENDFORM.                    " CHECK_BDC
    Answers will be awarded
    Thanks
    Rahul

    It is going into the second screen but whatever the value iam passing to incoterms2 it sis not populating when i run program, but in debugging value is coming.
    Is there any possibility of user exits attached to this ME21 transaction
    please advice
    thanks
    Madhukar Reddy

  • Generic BDC for VK11 - URGENT

    Hi
    Can any one tell me how to create <b>Generic BDC for  transaction VK11 (Creating condition records)</b>
    My actual requirement is like we need to create <b>condition record</b> for every material  with all the condition types exist for that material  for different key combinations . <b>A condition record for every material is to be created for different condition types and  different key combinations where material MATNR is a key field .For example we need to create condition records dynamically for condition types ZPR0, ZCM0 etc.. for different key combinations where matnr is a key field .</b>
    can anyone of you point out a way to me?
    Thanks in advance
    Shivakumar

    please   copy the  program and  use it 
    *  Report to Upload the pricing condtion records for materials.        *
    *  Program  : ZSDR_PRICE_UPLOAD                                        *
    *  Author   : girish.
    *  Description:                                                        *
    *  This report Creat pricing condition records for materials           *
    * Tables Used :                      SELECT UPDATE INSERT DELETE       *
    * MVKE                                                X                *
    * Input/Output Files:                                                  *
    * Transactions called:                                                 *
    * Includes:                                                            *
    * Run Frequency -                                                      *
    * Program History                                                      *
    * Date       Change No            Change Request   SAP Rel    NSC Rel  *
    *            Description                                               *
    *                                                  4.6C                *
    REPORT zsdr_price_upload  MESSAGE-ID zsdr_bdc_vk11  LINE-SIZE 150
    LINE-COUNT 75 .
    ******Internal Table for Header Data.
    TYPES : BEGIN OF type_header,
            kschl LIKE konv-kschl,
            vkorg LIKE vbak-vkorg,
            vtweg LIKE komg-spart,
            matnr LIKE mvke-matnr,
            kbetr(11) TYPE c,
            datab(10) TYPE c,
            datbi(10) TYPE c,
            END OF type_header.
    ****Internal Table for Item Level.
    TYPES : BEGIN OF type_item,
            kschl LIKE konv-kschl,
            vkorg LIKE vbak-vkorg,
            vtweg LIKE komg-spart,
            matnr LIKE mvke-matnr,
            kbetr(11)  TYPE c,
            datab(10) TYPE c,
            datbi(10) TYPE c,
           END OF type_item.
    ******Error Table For not found in MVKE.
    TYPES : BEGIN OF type_error ,
            kschl LIKE konv-kschl,
            vkorg LIKE vbak-vkorg,
            vtweg LIKE komg-spart,
            matnr LIKE mvke-matnr,
            kbetr LIKE konp-kbetr,
            datab(10) TYPE c,
            datbi(10) TYPE c,
            text(100) TYPE c,
            END OF type_error.
    ****For error Messages
    TYPES : BEGIN OF type_mtab,
            matnr   LIKE mara-matnr,
            msgtyp  LIKE bdcmsgcoll-msgtyp,
            msgid   LIKE bdcmsgcoll-msgid,
            msgnr   LIKE bdcmsgcoll-msgnr,
            text(100) TYPE c,
            END OF type_mtab.
    ****Internal Table
    TYPES: BEGIN OF type_mvke,
           matnr LIKE mvke-matnr,
           vkorg LIKE mvke-vkorg,
           vtweg LIKE mvke-vtweg,
           END OF type_mvke.
    ****Internal Table
    TYPES : BEGIN OF type_tvkov,
            vkorg LIKE tvkov-vkorg,
            vtweg LIKE tvkov-vtweg,
            END OF type_tvkov.
    ** Declaring Internal Tables
    DATA : t_header TYPE STANDARD TABLE OF type_header,
           t_item TYPE STANDARD TABLE OF type_item,
           t_mvke TYPE STANDARD TABLE OF type_mvke,
           t_tvkov TYPE STANDARD TABLE OF type_tvkov,
           t_error TYPE STANDARD TABLE OF type_error,
           t_mtab TYPE STANDARD TABLE OF type_mtab.
    ** Work Area Declaration.
    DATA : wa_header LIKE LINE OF t_header,
           wa_item LIKE LINE OF t_item,
           wa_error LIKE LINE OF t_error,
           wa_mtab LIKE LINE OF t_mtab,
           wa_tvkov LIKE LINE OF t_tvkov,
           wa_mvke LIKE LINE OF t_mvke.
    **Rows for Table with Excel Data********
    DATA: t_xls_file LIKE alsmex_tabline OCCURS 0 WITH HEADER LINE.
    ***Constant.
    DATA : c_params LIKE ctu_params.
    DATA : c_ans(1) TYPE c.
    DATA : v_count(4) TYPE c. " To show No.of records
    DATA :  bdctab LIKE bdcdata OCCURS 10 WITH HEADER LINE.      " BDCDATA
    DATA :  tmess_mtab  LIKE  bdcmsgcoll OCCURS 10 WITH HEADER LINE.
    **  SELECTION SCREEN
    SELECTION-SCREEN : BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    PARAMETERS : p_fname LIKE rlgrap-filename OBLIGATORY.
    SELECTION-SCREEN : END OF BLOCK b1.
    * END OF SELECTION SCREEN.
    DATA : repid LIKE sy-repid.
    DATA : v_matnr(50) TYPE c, "used for line items
           v_kbetr(50) TYPE c, "used for line items
           v_dat1(50) TYPE c,  "used for line items
           v_dat(50) TYPE c.   "used for line items
    DATA : v_lindx(5) TYPE n ,"index counter for first 14 records.
           v_lindx1(5) TYPE n  VALUE '01', "index counter for  13 records.
           v_item(5) TYPE c,  "To increment the line index
           v_pgedwn2  TYPE i . "For Pagedown Counter
    DATA:  v_currentrow TYPE i.  "For Current Row
    DATA  v_bdc(50) TYPE c." Text to apper in Confrim POPUP Window.
    ************AT SELECTION-SCREEN
    AT SELECTION-SCREEN  ON VALUE-REQUEST FOR p_fname.
      PERFORM get_filename USING p_fname.
    *************START-OF-SELECTION
    START-OF-SELECTION.
    ******Values for Ctu_params to Transaction
      c_params-defsize = 'X'.
      c_params-dismode = 'N'.
      c_params-updmode = 'S'.
    ******Refresh
      PERFORM f_refresh.
    *********To upload File.
      PERFORM upload_file.
    ****User Confrimation only BDC will Process
      IF c_ans = '1'.
    ** *** BDC Process.
        PERFORM read_data.
      ELSE.
        FORMAT COLOR 3 INTENSIFIED .
        WRITE:/ 'Selected not to Process the Upload'.
        EXIT.
      ENDIF.
    ******On completion of  Process Refresh the Internal Table
      REFRESH :  t_xls_file,
                   t_header,
                   t_item,
                   t_mvke,
                   t_tvkov.
      CLEAR :    t_xls_file,
                 wa_header,
                 wa_item,
                 wa_mvke,
                 wa_tvkov.
    ***********Display Messages
      WRITE : /01 'Status',19 'Status Text'.
      WRITE  AT 0(150) sy-uline.
      LOOP AT t_mtab INTO wa_mtab.
        WRITE :/01 wa_mtab-msgtyp,19 wa_mtab-text.
      ENDLOOP.
      SKIP 2.
      SORT t_error BY matnr.
      WRITE  AT 0(150) sy-uline.
      WRITE 'ERROR MESSAGES'.
      WRITE  AT 0(150) sy-uline.
      WRITE :/01 'Material.No',20 'Status Text'.
      WRITE  AT 0(150) sy-uline.
      LOOP AT t_error INTO wa_error WHERE matnr NE ' '.
        WRITE:/01 wa_error-matnr,20 wa_error-text.
      ENDLOOP.
    *&      Form  get_filename
    *       text
    *      -->P_FILENAME  text
    FORM get_filename USING    p_fname.
    *****To read the file from Presentation Server
      CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
       EXPORTING
         program_name        =  repid
        dynpro_number      ! ; =   syst-dynnr
          field_name          = p_fname
    *   STATIC              = ' '
        mask                = '*.XLS'
        CHANGING
          file_name           = p_fname
    EXCEPTIONS
       mask_too_long       = 1
       OTHERS              = 2
      IF sy-subrc <> 0.
    * * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *   WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    " get_filename
    *&      Form  upload_file
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM upload_file.
      DATA : frow VALUE 2 TYPE i,
             fcol VALUE 1 TYPE i,
             erow VALUE 10000 TYPE i,
             ecol VALUE 7  TYPE i,
             ecol1 VALUE 1 TYPE i,
             c_col1 TYPE i VALUE '0001',
             c_col2 TYPE i VALUE '0002',
             c_col3 TYPE i VALUE '0003',
           &nb! sp; c_col4 TYPE i VALUE '0004',
             c_col5 TYPE i VALUE '0005',
             c_col6 TYPE i VALUE '0006',
             c_col7 TYPE i VALUE '0007'.
    ***FM used to UPLOAD data from Flat file
      CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
           EXPORTING
                filename                = p_fname
                i_begin_col             = fcol
                i_begin_row             = frow
                i_end_col               = ecol
                i_end_row               = erow
           TABLES
                intern                  = t_xls_file
           EXCEPTIONS
                inconsistent_parameters = 1
                upload_ole              = 2
                OTHERS                  = 3.
      IF sy-subrc <> 0.
        MESSAGE e000.
      ENDIF.
    ****T_XLS_FILE is initial, stop the process & throw message
      IF t_xls_file[] IS INITIAL.
        FORMAT COLOR 6 ON INTENSIFIED ON.
        WRITE:/ 'No Data  Exists '.
        FORMAT COLOR OFF INTENSIFIED OFF.
        STOP.
      ELSE.
    * Sort table by rows and colums
        SORT t_xls_file BY row col.
    * Get first row retrieved
        READ TABLE t_xls_file INDEX 1.
    * Set first row retrieved to current row
        v_currentrow = t_xls_file-row.
    **Loop  to move data in internal Table
        LOOP AT t_xls_file .
    *   Reset values for next row
          IF t_xls_file-row NE v_currentrow.
            APPEND wa_header TO t_header.
            CLEAR wa_header.
            v_currentrow = t_xls_file-row.
          ENDIF.
          CASE t_xls_file-col.
            WHEN  c_col1.                              "Kschl
              wa_header-kschl = t_xls_file-value.
            WHEN c_col2.                              "Vkorg
              wa_header-vkorg = t_xls_file-value.
            WHEN c_col3.                              "vtweg
              wa_header-vtweg = t_xls_file-value.
            WHEN c_col4.                              "Matnr
              wa_header-matnr = t_xls_file-value.
            WHEN c_col5.                              "Kbetr
              wa_header-kbetr = t_xls_file-value.
            WHEN c_col6.                              "FROm
              wa_header-datab   = t_xls_file-value.
            WHEN c_col7.                              "TO
              wa_header-datbi   = t_xls_file-value.
          ENDCASE.
        ENDLOOP.
        APPEND wa_header TO t_header.
        CLEAR wa_header.
      ENDIF.
    ****To process the data
      PERFORM f_process.
    ENDFORM.                    " upload_file
    *&      Form  READ_DATA
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM read_data.
    ****To make Uniq Records in Header Level
      SORT t_header BY kschl vkorg vtweg.
      DELETE ADJACENT DUPLICATES FROM t_header COMPARING
                                       kschl vkorg vtweg .
      SORT t_item BY vkorg vtweg matnr.
      DATA : wa1_item TYPE type_item.
      DATA : l_cnt TYPE i.
      DATA : flag(1) TYPE c. "to process the Line item.
    ***Looping Header Table.
      LOOP AT t_header INTO wa_header.
        PERFORM bdc_dynpro      US! ING 'SAPMV13A' '0100'.
        PERFORM bdc_field       USING 'BDC_CURSOR'
                                      'RV13A-KSCHL'.
        PERFORM bdc_field       USING 'BDC_OKCODE'
                                        '=ANTA'.
        PERFORM bdc_field       USING 'RV13A-KSCHL'
                                      wa_header-kschl.
        PERFORM bdc_dynpro      USING 'SAPLV14A' '0100'.
        PERFORM bdc_field       USING 'BDC_CURSOR'
                                      'RV130-SELKZ(03)'.
        PERFORM bdc_field       USING 'BDC_OKCODE'
                                      '=WEIT'.
        PERFORM bdc_field       USING 'RV130-SELKZ(03)'
                                      'X'.
        PERFORM bdc_dynpro      USING 'SAPMV13A' '1004'.
        PERFORM bdc_field       USING 'BDC_CURSOR'
                                      'KOMG-VKORG'.
        PERFORM bdc_field       USING 'KOMG-VKORG'
                                       wa_header-vkorg.
        PERFORM bdc_field       USING 'KOMG-VTWEG'
                                       wa_header-vtweg.
    ****To handle Line Items.
        LOOP AT t_item INTO wa1_item WHERE vkorg = wa_header-vkorg AND
                                      vtweg = wa_header-vtweg.
          wa_item = wa1_item.
    ******Flag Set only After processing  first 14 records .
          IF flag = ' '.
            v_lindx  = v_lindx + 01.
            SHIFT  v_lindx LEFT DELETING LEADING '0'.
            v_item  = v_lindx .
            CONCATENATE 'KOMG-MATNR(' v_item ')'  INTO v_matnr.
            PERFORM bdc_field           USING v_matnr
                                          wa_item-matnr.
            CONCATENATE 'KONP-KBETR(' v_item ')' INTO v_kbetr.
            PERFORM bdc_field       USING v_kbetr
                                          wa_item-kbetr.
            CONCATENATE 'RV13A-DATAB(' v_item ')' INTO v_dat.
            PERFORM bdc_field       USING  v_dat
                                          wa_item-datab.
            CONCATENATE 'RV13A-DATBI(' v_item ')' INTO v_dat1.
            PERFORM bdc_field       USING  v_dat1
                                          wa_item-datbi.
            IF  v_item = 14.
              flag = 'X'.
              PERFORM bdc_field       USING 'BDC_OKCODE'
                                                  '/00'.
              PERFORM bdc_field       USING 'BDC_OKCODE'
                                                 '=P+'.
              PERFORM bdc_dynpro      USING 'SAPMV13A' '1004'.
              CLEAR v_lindx.
              CLEAR v_item.
              CONTINUE.
            ENDIF.
          ENDIF.
    ***Flag is Set  after Processing of 14 records.
    ****** TO process rest of Records
          IF flag = 'X'.
            v_pgedwn2  = v_pgedwn2 + 1.
            v_lindx1  = v_lindx1 + 01.
            SHIFT  v_lindx1 LEFT DE! LETING LEADING '0'.
            v_item  = v_lindx1 .
            CONCATENATE 'KOMG-MATNR(' v_it! em ')'  INTO v_matnr.
            PERFORM bdc_field           USING v_matnr
                                          wa_item-matnr.
            CONCATENATE 'KONP-KBETR(' v_item ')' INTO v_kbetr.
            PERFORM bdc_field       USING v_kbetr
                                          wa_item-kbetr.
            CONCATENATE 'RV13A-DATAB(' v_item ')' INTO v_dat.
            PERFORM bdc_field       USING  v_dat
                                          wa_item-datab.
            CONCATENATE 'RV13A-DATBI(' v_item ')' INTO v_dat1.
            PERFORM bdc_field       USING  v_dat1
                                          wa_item-datbi.
            IF v_pgedwn2 = 13.
              PERFORM bdc_field       USING 'BDC_OKCODE'
                                                  '/00'.
              PERFORM bdc_field       USING 'BDC_OKCODE'
                                                 '=P+'.
              PERFORM bdc_dynpro      USING 'SAPMV13A' '1004'.
              v_pgedwn2 = 0.
              v_lindx1 = 1.
              CLEAR v_item.
              CONTINUE.
            ENDIF.
          ENDIF.
        ENDLOOP.
        PERFORM bdc_field       USING 'BDC_OKCODE'
                                   '=SICH'.
    ****** Calling Transaction after Processing All items.
        CALL TRANSACTION 'VK11' USING bdctab
                           OPTIONS FROM c_params MESSAGES INTO tmess_mtab.
        REFRESH bdctab.
        CLEAR : bdctab.
        CLEAR : wa_item.
        CLEAR : wa1_item.
        CLEAR : wa_header.
        CLEAR : l_cnt.
        CLEAR : v_lindx1.
        CLEAR:  v_pgedwn2,v_lindx.
        LOOP AT tmess_mtab .
          l_cnt =  l_cnt + 1.
          READ TABLE t_item INTO wa_item INDEX l_cnt .
          CALL FUNCTION 'MASS_MESSAGE_GET' "To get the Message Text
               EXPORTING
                    arbgb             = tmess_mtab-msgid
                    msgnr             = tmess_mtab-msgnr
                    msgv1             = tmess_mtab-msgv1
                    msgv2             = tmess_mtab-msgv2
                    msgv3             = tmess_mtab-msgv3
                    msgv4           !   = tmess_mtab-msgv4
               IMPORTING
                    msgtext           = wa_mtab-text
               EXCEPTIONS
                    message_not_found = 1
                    OTHERS            = 2.
          IF sy-subrc <> 0.
    *        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *        WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
          ENDIF.
          wa_mtab-matnr   = wa_item-matnr.
          wa_mtab-msgtyp  = tmess_mtab-msgtyp.
          wa_mtab-msgid   = tmess_mtab-msgid.
          wa_mtab-msgn! r   = tmess_mtab-msgnr.
          APPEND wa_mtab TO t_mtab.
          CLEAR wa_mtab-text.
          CLEAR wa_item.
        ENDLOOP.
      ENDLOOP.
    ENDFORM.                    " READ_DATA
    *&      Form  BDC_DYNPRO
    *       text
    *      -->P_0300   text
    *      -->P_0301   text
    *        Start new screen                                              *
    FORM bdc_dynpro USING program dynpro.
      CLEAR bdctab.
      bdctab-program  = program.
      bdctab-dynpro   = dynpro.
      bdctab-dynbegin = 'X'.
      APPEND bdctab.
    ENDFORM.                    " BDC_DYNPRO
    *&      Form  BDC_FIELD
    *       text
    *      -->P_0305   text
    *      -->P_WA_HEADER_KSCHL  text
    *        Insert field                                                  *
    FORM bdc_field USING fnam fval.
      CLEAR bdctab.
      bdctab-fnam = fnam.
      bdctab-fval = fval.
      APPEND bdctab.
    ENDFORM.                    " BDC_FIELD
    *&      Form  bdc_trc_ansaction
    *       text
    *      -->P_0527   text
    *&      Form  f_Process
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM f_process.
      DATA : l_todate(12) TYPE c,
             l_frdate(12) TYPE c.
    ***Select for all entries of material in Header "Flat File Materials".
      IF NOT t_header[] IS INITIAL.
       SELECT matnr vkorg vtweg FROM mvke INTO TABLE t_mvke FOR ALL ENTRIES
                               IN t_header WHERE matnr = t_header-matnr AND
                                                 vkorg = t_header-vkorg AND
                                                     vtweg = t_header-vtweg.
      ENDIF.
    *********select Sales.org & Dist.channel.
      IF NOT t_header[] IS INITIAL.
        SELECT vkorg vtweg FROM tvkov INTO TABLE t_tvkov FOR ALL ENTRIES IN
                                    t_header WHERE vkorg = t_header-vkorg
                                               AND vtweg = t_header-vtweg.
      ENDIF.
    ***Checking for material in Sales Master Table
      SORT t_mvke BY matnr vkorg vtweg.
      SORT t_tvkov BY vkorg vtweg.
      LOOP AT t_header INTO wa_header.
        READ TABLE t_mvke INTO wa_mvke WITH KEY matnr = wa_header-matnr
                                                 vkorg = wa_header-vkorg
                                    ! ;  vtweg = wa_header-vtweg BINARY SEARCH.
        IF sy-subrc <> 0.
          wa_error = wa_header.
        &nb! sp; MOVE text-011 TO  wa_error-text.
          APPEND wa_error TO t_error.
          DELETE TABLE t_header FROM wa_header.
        ELSE.
    ********Date Validations
          IF ( wa_header-datab  NE ' ! ;  '  AND  wa_header-datbi NE  '  ' ) .
            l_todate = wa_header-datab.
            l_frdate = wa_header-datbi.
            REPLACE '.' INTO l_toda! te WITH ''.
            REPLACE '.' INTO l_todate WITH ''.
            CONDENSE l_todate NO-GAPS.
            REPLACE '.' INTO l_frdate WITH ''.
            REPLACE '.' INTO l_frdate WITH ''.
            CONDENSE l_frdate NO-GAPS.
            IF l_frdate < l_todate.
              wa_error = wa_header .
              MOVE text-012 TO wa_error-text.
              APPEND wa_error TO t_error.
              DELETE TABLE t_header FROM wa_header.
            ENDIF.
          ELSE.
            wa_error = wa_header .
            MOVE text-016 TO wa_error-text.
            APPEND wa_error TO t_error.
            DELETE TABLE t_header FROM wa_header.
          ENDIF.
        ENDIF.
    ********Rate Validation.
        IF wa_header-kbetr = '   '.
          wa_error = wa_header .
          MOVE text-017 TO wa_error-text.
          APPEND wa_error TO t_error.
          DELETE TABLE t_header FROM wa_header.
        ENDIF.
        READ TABLE t_tvkov INTO wa_tvkov WITH KEY vkorg = wa_header-vkorg
                                                   BINARY SEARCH.
        IF sy-subrc  = 0.
          READ TABLE t_tvkov INTO wa_tvkov WITH KEY vtweg = wa_header-vtweg
                                                       BINARY SEARCH.
          IF sy-subrc  <> 0.
            wa_error = wa_header.
            MOVE text-015 TO  wa_error-text.
            WRITE wa_header-vtweg TO wa_error-text+13(4).
            APPEND wa_error TO t_error.
          ENDIF.
        ELSE.
          wa_error = wa_header.
          MOVE text-013 TO  wa_error-text.
          WRITE wa_header-vkorg TO wa_error-text+9(4).
          APPEND wa_error TO t_error.
        ENDIF.
        CLEAR wa_header.
      ENDLOOP.
    *****Deleting Duplicate Material  Form Header "Flat File Data".
      SORT t_header BY kschl vkorg vtweg matnr.
      DELETE ADJACENT DUPLICATES FROM t_header COMPARING
            kschl! vkorg vtweg matnr .
    *  ****Data Moving from Header to Item Level.
      t_item[] = t_header[].
    *To count No.of records in Item Table.
      DESCRIBE TABLE t_item  LINES v_count.
      CONCATENATE text-014 ' ' v_count INTO  v_bdc.
    ****Popup to get Confirmation from user to process BDC
      CALL FUNCTION 'POPUP_TO_CONFIRM'
           EXPORTING
                titlebar       = 'Confirmation of File Data'
                text_question  = v_bdc
                text_button_1  = 'Confirm'
                text_button_2  = 'Cancel Run'
                default_button = '1'
           IMPORTING
                answer         = c_ans.
      IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-! MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    " f_Process
    *&      Form  f_Refresh
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM f_refresh.
      REFRESH :  t_xls_file,
                 t_header,
                 t_item,
                 t_mvke,
                 t_tvkov,
                 t_error,
                 t_mtab.
      CLEAR :    t_xls_file,
                 wa_header,
                 wa_item,
                 wa_mvke,
                 wa_tvkov,
                 wa_error,
                 wa_mtab.
    ENDFORM.                    " f_Refresh
    reward  point s  if it is usefull ....
    girish

  • Generic BDC for VK11

    Hi
    Can any one tell me how to create <b>Generic BDC for  transaction VK11 (Creating condition records)</b>
    My actual requirement is like we need to create <b>condition record</b> for  every  material  with all the condition types exist for that material  for different key combinations dynamically . <b>A condition record for  every material is to be created for different condition types and  different key combinations dynamically where material MATNR is a key field</b>  for example i need to create a conditon record for condition type <b>ZPR0,ZPR1</b> etc dynamically for different key combinations.
    can anyone of you point out a way to me?
    Thanks in advance
    Shivakumar

    Hi
    Can any one tell me how to create <b>Generic BDC for  transaction VK11 (Creating condition records)</b>
    My actual requirement is like we need to create <b>condition record</b> for  every  material  with all the condition types exist for that material  for different key combinations dynamically . <b>A condition record for  every material is to be created for different condition types and  different key combinations dynamically where material MATNR is a key field</b>  for example i need to create a conditon record for condition type <b>ZPR0,ZPR1</b> etc dynamically for different key combinations.
    can anyone of you point out a way to me?
    Thanks in advance
    Shivakumar

  • Problem in BDC for PFCG

    hi all,
    I want to create a BDC for PFCG to create a new role and the assign Transaction to that role.
    After Recording when iam running through SHDB it works fine in foreground but after transfering that recording to ABAP editor (se38) then it is not running. The Error is....
    there are Role and Description field in header when Ok-code = SAVE appear then it is showing a mandatory Saving dialog box and when i press enter throws me out in se38 bdc but when iam running through SHDB recording bdc and when Ok-code = SAVE appear then it is showing a mandatory Saving dialog box and when i press enter it enter Menu tab and it go ahead and works fine.
    __Is there any BAPI to CREATE ROLE AND ASSIGN TRANSACTION TO THAT ROLE for PFCG.__

    Hello,
    FYI i also had the same req. some months back.
    You can make use of the following FMs: PRGN1251 & PRGN1252 fms to update PFCG.
    These tables directly update AGR_1251 & AGR_1252 tables & write the corres. change docs as well
    BR,
    Suhas

  • BDC for FS00

    Hi,
    Is it advisable to create a BDC for FS00 and create GL for each company codes one by one or is it best to copy GL from one company code to another?
    Is it possible to write a BDC for creation or copy of GL?

    The BDC recording code has been given to me. I have to create the program. I have also created the program but program is getting stuck.
    Please find below the bdc code.
    perform bdc_dynpro      using 'SAPLGL_ACCOUNT_MASTER_MAINTAIN' '2001'.
          perform bdc_field       using 'BDC_OKCODE'
                                       '=%_GC 120 1'.
          perform bdc_field       using 'BDC_CURSOR'
                                        'GLACCOUNT_SCREEN_KEY-SAKNR'.
          perform bdc_dynpro      using 'SAPLSPO4' '0300'.
          perform bdc_field       using 'BDC_CURSOR'
                                        'SVALD-VALUE(01)'.
          perform bdc_field       using 'BDC_OKCODE'
                                        '=FURT'.
          perform bdc_field       using 'SVALD-VALUE(01)'
                                        W_XK01-COCD.
          perform bdc_dynpro      using 'SAPLGL_ACCOUNT_MASTER_MAINTAIN' '2001'.
          perform bdc_field       using 'BDC_OKCODE'
                                        '=%_GC 120 1'.
          perform bdc_dynpro      using 'SAPLSPO4' '0300'.
          perform bdc_field       using 'BDC_CURSOR'
                                        'SVALD-VALUE(02)'.
          perform bdc_field       using 'BDC_OKCODE'
                                        '=FURT'.
          perform bdc_field       using 'SVALD-VALUE(01)'
                                        W_XK01-GLNO.
          perform bdc_field       using 'SVALD-VALUE(02)'
                                        W_XK01-COCD.
          perform bdc_dynpro      using 'SAPLGL_ACCOUNT_MASTER_MAINTAIN' '2001'.
          perform bdc_field       using 'BDC_OKCODE'
                                        '=2102_BS_PL'.
          perform bdc_field       using 'BDC_CURSOR'
                                        'GLACCOUNT_SCREEN_COA-XBILK'.
          perform bdc_field       using 'GLACCOUNT_SCREEN_COA-XPLACCT'
                                        W_XK01-XPLACCT.
          perform bdc_field       using 'GLACCOUNT_SCREEN_COA-XBILK'
                                        W_XK01-XBILK.
          perform bdc_dynpro      using 'SAPLGL_ACCOUNT_MASTER_MAINTAIN' '2001'.
          perform bdc_field       using 'BDC_OKCODE'
                                        '=2102_GROUP'.
          perform bdc_field       using 'BDC_CURSOR'
                                        'GLACCOUNT_SCREEN_COA-KTOKS'.
          perform bdc_field       using 'GLACCOUNT_SCREEN_COA-KTOKS'
                                        W_XK01-KTOKS.
          perform bdc_field       using 'GLACCOUNT_SCREEN_COA-XBILK'
                                        W_XK01-XBILK.
          perform bdc_dynpro      using 'SAPLGL_ACCOUNT_MASTER_MAINTAIN' '2001'.
          perform bdc_field       using 'BDC_OKCODE'
                                        '=TAB02'.
          perform bdc_field       using 'GLACCOUNT_SCREEN_COA-KTOKS'
                                        W_XK01-KTOKS.
          perform bdc_field       using 'GLACCOUNT_SCREEN_COA-XBILK'
                                        W_XK01-XBILK.
          perform bdc_field       using 'BDC_CURSOR'
                                        'GLACCOUNT_SCREEN_COA-TXT50_ML'.
          perform bdc_field       using 'GLACCOUNT_SCREEN_COA-TXT20_ML'
                                        W_XK01-TXT20_ML.
          perform bdc_field       using 'GLACCOUNT_SCREEN_COA-TXT50_ML'
                                        W_XK01-TXT50_ML.
          perform bdc_dynpro      using 'SAPLGL_ACCOUNT_MASTER_MAINTAIN' '2001'.
          perform bdc_field       using 'BDC_OKCODE'
                                        '=TAB03'.
          perform bdc_field       using 'GLACCOUNT_SCREEN_CCODE-WAERS'
                                        W_XK01-WAERS.
          perform bdc_field       using 'GLACCOUNT_SCREEN_CCODE-XSALH'
                                        W_XK01-XSALH.
          perform bdc_field       using 'GLACCOUNT_SCREEN_CCODE-XMWNO'
                                        W_XK01-XMWNO.
          perform bdc_field       using 'BDC_CURSOR'
                                        'GLACCOUNT_SCREEN_CCODE-ZUAWA'.
          perform bdc_field       using 'GLACCOUNT_SCREEN_CCODE-XKRES'
                                        W_XK01-XKRES.
          perform bdc_field       using 'GLACCOUNT_SCREEN_CCODE-ZUAWA'
                                        W_XK01-ZUAWA.
          perform bdc_dynpro      using 'SAPLGL_ACCOUNT_MASTER_MAINTAIN' '2001'.
          perform bdc_field       using 'BDC_OKCODE'
                                        '=SAVE'.
          perform bdc_field       using 'GLACCOUNT_SCREEN_CCODE-FSTAG'
                                        W_XK01-FSTAG.
          perform bdc_field       using 'GLACCOUNT_SCREEN_CCODE-XGKON'
                                        W_XK01-XGKON.
          perform bdc_field       using 'BDC_CURSOR'
                                        'GLACCOUNT_SCREEN_CCODE-ZINRT'.
          perform bdc_field       using 'GLACCOUNT_SCREEN_CCODE-ZINRT'
                                        W_XK01-ZINRT.
          perform bdc_transaction using 'FS00'.

  • PROBLEM IN BDC FOR WHILE CREATING PGI

    Hi All,
    I am using BDC program to Create PGI automatically from custom development program for CASHTILL . In Vl02n there is one Custom development screen '9999', it will be called when press POSTGOODSISSUE button in VL02n. I am filling this screen also Using BDC. This custom screen is called in USEREXIT SAPMV50A include mv50afz1 in USEREXIT_SAVE_DOCUMENT_PREPARE. This code will update one Custome Table.
    Problem is when i run BDC it's updatting the custom table,but it's not creating PGI,but when i run the secondtime my BDC program it's creating PGI. Please help me why i am getting this error? I pasted my code here,
    REPORT  YVL.
    DATA T_CODE(10) TYPE C VALUE 'VL02N'.
    DATA:  T_BDCDATA TYPE STANDARD TABLE OF BDCDATA     WITH HEADER LINE.
    DATA:  h_bdcdata  TYPE STANDARD TABLE OF BDCDATA     WITH HEADER LINE.
    DATA : L_DATE(10) TYPE C,
           L_DATE1(10) TYPE C.
    CALL FUNCTION 'CONVERT_DATE_TO_EXTERNAL'
       EXPORTING
         DATE_INTERNAL              = SY-DATUM
       IMPORTING
         DATE_EXTERNAL              = L_DATE1
       EXCEPTIONS
         DATE_INTERNAL_IS_INVALID   = 1
         OTHERS                     = 2.
    perform bdc_dynpro      using 'SAPMV50A' '4004'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'LIKP-VBELN'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=WABU_T'.
    perform bdc_field       using 'LIKP-VBELN'
                                  '80003504'.
    perform bdc_dynpro      using 'SAPLZSD_PROOF_DELIV' '9999'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'ZSD_PROOF_DELIV-NAME_LAST'.
    perform bdc_field       using 'ZSD_PROOF_DELIV-NAME_FIRST'
                                  'cash'.
    perform bdc_field       using 'ZSD_PROOF_DELIV-NAME_LAST'
                                  'sales'.
    perform bdc_field       using 'ZSD_PROOF_DELIV-YSDATE'
                                  L_DATE1.
    perform bdc_field       using 'ZSD_PROOF_DELIV-YSTIME'
                                  '11:14:01'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=WABU_T'.
    COMMIT WORK.
    CALL TRANSACTION  T_CODE USING t_bdcdata.
    FORM bdc_dynpro USING program dynpro.
      CLEAR h_bdcdata.
      h_bdcdata-program  = program.
      h_bdcdata-dynpro   = dynpro.
      h_bdcdata-dynbegin = 'X'.
      APPEND h_bdcdata TO t_bdcdata.
    ENDFORM.                    "BDC_DYNPRO
    FORM bdc_field USING fnam fval.
      CLEAR h_bdcdata.
      h_bdcdata-fnam = fnam.
      h_bdcdata-fval = fval.
      APPEND h_bdcdata TO t_bdcdata.
    ENDFORM.                    "BDC_FIELD

    At first, I would suggest you try with VL02 Tcode rather doing for enjoy transactions.
    Updation of Z table should be sync with your PGI transaction. Here the INSERT/UPDATE should in PERFORM ON COMMIT so the both transaction and Z table will be in sync.
    what is the error you are getting for first time execution? Do you need commit work before call transaction?
    Regds
    Manohar

  • Can we create a single bdc for raw materials , and for some other transacti

    hi
    can we create a single bdc for raw materials , and for some other transaction? how?

    Hi Jyothsna
    For one transaction you will have to build your bdc table according to the recording for that transaction and then call that transaction using the bdc table. For another transaction , you will again have to build the bdc table with the details of that transaction.
    You cannot call all at one shot.
    Cheers
    shivika

  • Error when creating a bdc for asset master upload

    I am getting a warning message (AA186), when changing the depreciation start date to capitalization date. It says,
    "Different Order Dep. start date in depreciation area 01. Check"
    This error is a problem in creating the BDC for asset master upload. We have only one depreciaton area 01 (book dep).
    Please help.

    This is normal message you get when you try to change depn start date. I think this should not be a problem for BDC posting. This message can always be bypassed.

  • BDC for PA30 action hire is not creating entry in IT 1001

    Hello All,
       I created a BDC for to create hire action in system to create some dummy data, but its not creating entry in infotype 1001 for relation between person (P) and position (S). If i create entry in PA30 it create ebtry, if i try BDC in Dialog mode even then its not creating it.
      I read a lot about Dynamic action in this kind of issue but i seen table T588Z but there is no any insert dynamic action for IT 1001.
    Can anybody throw some light on the cause of the same.
    i tried to create same data with FM HR_MIANTAIN_MASTERDATA but i have to drop that idea becasue it was not able to crate record with empty PERNR field. if your answer is use this FM then please provide some working code as i searched a lot on the same issue but no any concrete proof on the same.
    appreciate any reply.
    Mani

    Hi,
    Are you getting any error?
    If not i think you have to lock the employee before creating an entry to the IT 1001 using FM
    'BAPI_EMPLOYEE_ENQUEUE'
    and create an entry to IT 1001 using BDC or HR_MIANTAIN_MASTERDATA
    and unlock an employee by using FM
    'BAPI_EMPLOYEE_DEQUEUE'
    Regards
    Krishna

  • Creating bdc for transaction f-02 ?

    Hi People,
    I am going a bdc for transaction f-02 ..... my template involves 7 posting keys ( 40 50 31 01 29 09 70 ) ... depending up
    on the posting key the next screen will change .......... can you people tel me how to do this and what are all the logic
    involved in this program ?
    thanks u all in advance.
    Siva

    Hi,
    Please use the following format for your upload file template
    DocDate1    ComCd1    Currency1    pstky1
    DocDate1    ComCd1    Currency1    pstky2
    DocDate1    ComCd1    Currency1    pstky3
    DocDate2    ComCd2    Currency2    pstky1
    DocDate2    ComCd2    Currency2    pstky2
    Then use the following logic.
    At New Currency1
    add the header data
    DocDate1    ComCd1    Currency1
    Thus this code will run only once for every new Header
    and remain in the screen till posting key are entered.
    Regards,
    Lokesh
    Edited by: Lokesh Tibbani on Sep 5, 2008 12:17 PM

  • BDC for C201(Master Recipe Create)

    Dear,
    Please help me in the following situation:
    I have written a BDC for transaction code C201 for Master Recipe Creation. Its running ok.
    But I have doubts like
    for the 1st table control:
    1) if for one operartion there are more than 1 phases
        then what precautions are needed for page down.
    for the 2nd level inner table control:
    1) I am in the process of coding pagedown for this 2nd table control. If I have to code for it what all precautions will I have to take?
    And in total what all precautions will I have to take?
    How feasible is this BDC?
    I have searched for BAPI, but did not find one.
    Kindly help me. I am under client pressure.
    Thanks.
    Regards,
    Shambhavi.
    Edited by: Shambhavi Salunkhe on Jun 23, 2008 9:40 PM

    Hi,
    In C201 transaction we have a table control in the operations screen. below the table control we have some push buttons and a input text field, we can make use this field to handle the table control. If you are insertinga first operation, enter the value in first row of the table control. for the second operation onwards enter max valye like 99999 in the input text box and click on enter. all the previous rows will scroll up and always second row of the table control will be free, so you can put the data in the second row. in the same way you will have some button to handle the other table control too .I hope this will help You
    Thanks,
    rajinikanth
    Edited by: Rajinikanth G on Jun 23, 2008 6:53 PM

  • BDC for ME21N Transaction

    Dear All,
    I have a requirement to create PO using transaction ME21N. I had written a code to create PO using BDC for transaction ME21. But the user wants it to be modified to ME21N. The user wants the PO created in the foreground like the one i created fro ME21. But is it possible to use BDC for ME21N or is there any other way i can change the BAPI to foreground processing like in BDC?
    Regards,
    Karthik

    Hi Raghavender,
    This is a report to display and validate the RFQ's. And once the user selects the RFQ and clicks on Create PO from RFQ push button, it should go to transaction 'ME21N' with values from RFQ. ( similar to what we do in ME21N, when we drag RFQ from the documents overview and drop it into cart, the values are populated). I want the similar functionality to happen when the user clicks on clicks on Create PO push button. But it should happen only in the foreground and not background.
    Regards,
    Karthik

  • BDC for ME21N (Flat file format)

    Hello,
         I have to write a BDC for ME21N(stock transfer).... Someone pls give me the format of flat file... we need separate files for header and items or only one file is enough??? pls someone send me the format and code......
    my email id is [email protected]
    Thanks in advance...
    Regards,
    Maya.

    Hi
    see this and do accordingly
    REPORT zmm_bdcp_purchaseorderkb02
    NO STANDARD PAGE HEADING LINE-SIZE 255.
    Declaring internal tables *
    *-----Declaring line structure
    DATA : BEGIN OF it_dummy OCCURS 0,
    dummy(255) TYPE c,
    END OF it_dummy.
    *-----Internal table for line items
    DATA : BEGIN OF it_idata OCCURS 0,
    ematn(18), "Material Number.
    menge(13), "Qyantity.
    netpr(11), "Net Price.
    werks(4), "Plant.
    ebelp(5), "Item Number.
    END OF it_idata.
    *-----Deep structure for header data and line items
    DATA : BEGIN OF it_me21 OCCURS 0,
    lifnr(10), "Vendor A/c No.
    bsart(4), "A/c Type.
    bedat(8), "Date of creation of PO.
    ekorg(4), "Purchasing Organisation.
    ekgrp(3), "Purchasing Group.
    x_data LIKE TABLE OF it_idata,
    END OF it_me21.
    DATA : x_idata LIKE LINE OF it_idata.
    DATA : v_delimit VALUE ','.
    DATA : v_indx(3) TYPE n.
    DATA : v_fnam(30) TYPE c.
    DATA : v_count TYPE n.
    DATA : v_ne TYPE i.
    DATA : v_ns TYPE i.
    *include bdcrecx1.
    INCLUDE zmm_incl_purchaseorderkb01.
    Search help for file *
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
    CALL FUNCTION 'F4_FILENAME'
    EXPORTING
    program_name = syst-cprog
    dynpro_number = syst-dynnr
    IMPORTING
    file_name = p_file.
    START-OF-SELECTION.
    To upload the data into line structure *
    CALL FUNCTION 'WS_UPLOAD'
    EXPORTING
    filename = p_file
    filetype = 'DAT'
    TABLES
    data_tab = it_dummy.
    Processing the data from line structure to internal tables *
    REFRESH:it_me21.
    CLEAR :it_me21.
    LOOP AT it_dummy.
    IF it_dummy-dummy+0(01) = 'H'.
    v_indx = v_indx + 1.
    CLEAR it_idata.
    REFRESH it_idata.
    CLEAR it_me21-x_data.
    REFRESH it_me21-x_data.
    SHIFT it_dummy.
    SPLIT it_dummy AT v_delimit INTO it_me21-lifnr
    it_me21-bsart
    it_me21-bedat
    it_me21-ekorg
    it_me21-ekgrp.
    APPEND it_me21.
    ELSEIF it_dummy-dummy+0(01) = 'L'.
    SHIFT it_dummy.
    SPLIT it_dummy AT v_delimit INTO it_idata-ematn
    it_idata-menge
    it_idata-netpr
    it_idata-werks
    it_idata-ebelp.
    APPEND it_idata TO it_me21-x_data.
    MODIFY it_me21 INDEX v_indx.
    ENDIF.
    ENDLOOP.
    To open the group *
    PERFORM open_group.
    To populate the bdcdata table for header data *
    LOOP AT it_me21.
    v_count = v_count + 1.
    REFRESH it_bdcdata.
    PERFORM subr_bdc_table USING: 'X' 'SAPMM06E' '0100',
    ' ' 'BDC_CURSOR' 'EKKO-LIFNR',
    ' ' 'BDC_OKCODE' '/00',
    ' ' 'EKKO-LIFNR' it_me21-lifnr,
    ' ' 'RM06E-BSART' it_me21-bsart,
    ' ' 'RM06E-BEDAT' it_me21-bedat,
    ' ' 'EKKO-EKORG' it_me21-ekorg,
    ' ' 'EKKO-EKGRP' it_me21-ekgrp,
    ' ' 'RM06E-LPEIN' 'T'.
    PERFORM subr_bdc_table USING: 'X' 'SAPMM06E' '0120',
    ' ' 'BDC_CURSOR' 'RM06E-EBELP',
    ' ' 'BDC_OKCODE' '/00'.
    MOVE 1 TO v_indx.
    *-----To populate the bdcdata table for line item data
    LOOP AT it_me21-x_data INTO x_idata.
    CONCATENATE 'EKPO-EMATN(' v_indx ')' INTO v_fnam.
    PERFORM subr_bdc_table USING ' ' v_fnam x_idata-ematn.
    CONCATENATE 'EKPO-MENGE(' v_indx ')' INTO v_fnam.
    PERFORM subr_bdc_table USING ' ' v_fnam x_idata-menge.
    CONCATENATE 'EKPO-NETPR(' v_indx ')' INTO v_fnam.
    PERFORM subr_bdc_table USING ' ' v_fnam x_idata-netpr.
    CONCATENATE 'EKPO-WERKS(' v_indx ')' INTO v_fnam.
    PERFORM subr_bdc_table USING ' ' v_fnam x_idata-werks.
    v_indx = v_indx + 1.
    PERFORM subr_bdc_table USING: 'X' 'SAPMM06E' '0120',
    ' ' 'BDC_CURSOR' 'RM06E-EBELP',
    ' ' 'BDC_OKCODE' '/00'.
    ENDLOOP.
    PERFORM subr_bdc_table USING: 'X' 'SAPMM06E' '0120',
    ' ' 'BDC_CURSOR' 'RM06E-EBELP',
    ' ' 'BDC_OKCODE' '=BU'.
    PERFORM bdc_transaction USING 'ME21'.
    ENDLOOP.
    PERFORM close_group.
    End of selection event *
    END-OF-SELECTION.
    IF session NE 'X'.
    *-----To display the successful records
    WRITE :/10 text-001. "Sucess records
    WRITE :/10 SY-ULINE(20).
    SKIP.
    IF it_sucess IS INITIAL.
    WRITE :/ text-002.
    ELSE.
    WRITE :/ text-008, "Total number of Succesful records
    35 v_ns.
    SKIP.
    WRITE:/ text-003, "Vendor Number
    17 text-004, "Record number
    30 text-005. "Message
    ENDIF.
    LOOP AT it_sucess.
    WRITE:/4 it_sucess-lifnr,
    17 it_sucess-tabix CENTERED,
    30 it_sucess-sucess_rec.
    ENDLOOP.
    SKIP.
    *-----To display the erroneous records
    WRITE:/10 text-006. "Error Records
    WRITE:/10 SY-ULINE(17).
    SKIP.
    IF it_error IS INITIAL.
    WRITE:/ text-007. "No error records
    ELSE.
    WRITE:/ text-009, "Total number of erroneous records
    35 v_ne.
    SKIP.
    WRITE:/ text-003, "Vendor Number
    17 text-004, "Record number
    30 text-005. "Message
    ENDIF.
    LOOP AT it_error.
    WRITE:/4 it_error-lifnr,
    17 it_error-tabix CENTERED,
    30 it_error-error_rec.
    ENDLOOP.
    REFRESH it_sucess.
    REFRESH it_error.
    ENDIF.
    CODE IN INCLUDE.
    Include ZMM_INCL_PURCHASEORDERKB01
    DATA: it_BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
    DATA: it_MESSTAB LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.
    DATA: E_GROUP_OPENED.
    *-----Internal table to store sucess records
    DATA:BEGIN OF it_sucess OCCURS 0,
    msgtyp(1) TYPE c,
    lifnr LIKE ekko-lifnr,
    tabix LIKE sy-tabix,
    sucess_rec(125),
    END OF it_sucess.
    DATA: g_mess(125) type c.
    *-----Internal table to store error records
    DATA:BEGIN OF it_error OCCURS 0,
    msgtyp(1) TYPE c,
    lifnr LIKE ekko-lifnr,
    tabix LIKE sy-tabix,
    error_rec(125),
    END OF it_error.
    Selection screen
    SELECTION-SCREEN BEGIN OF LINE.
    PARAMETERS session RADIOBUTTON GROUP ctu. "create session
    SELECTION-SCREEN COMMENT 3(20) text-s07 FOR FIELD session.
    SELECTION-SCREEN POSITION 45.
    PARAMETERS ctu RADIOBUTTON GROUP ctu. "call transaction
    SELECTION-SCREEN COMMENT 48(20) text-s08 FOR FIELD ctu.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 3(20) text-s01 FOR FIELD group.
    SELECTION-SCREEN POSITION 25.
    PARAMETERS group(12). "group name of session
    SELECTION-SCREEN COMMENT 48(20) text-s05 FOR FIELD ctumode.
    SELECTION-SCREEN POSITION 70.
    PARAMETERS ctumode LIKE ctu_params-dismode DEFAULT 'N'.
    "A: show all dynpros
    "E: show dynpro on error only
    "N: do not display dynpro
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 48(20) text-s06 FOR FIELD cupdate.
    SELECTION-SCREEN POSITION 70.
    PARAMETERS cupdate LIKE ctu_params-updmode DEFAULT 'L'.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 3(20) text-s03 FOR FIELD keep.
    SELECTION-SCREEN POSITION 25.
    PARAMETERS: keep AS CHECKBOX. "' ' = delete session if finished
    "'X' = keep session if finished
    SELECTION-SCREEN COMMENT 48(20) text-s09 FOR FIELD e_group.
    SELECTION-SCREEN POSITION 70.
    PARAMETERS e_group(12). "group name of error-session
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 51(17) text-s03 FOR FIELD e_keep.
    SELECTION-SCREEN POSITION 70.
    PARAMETERS: e_keep AS CHECKBOX. "' ' = delete session if finished
    "'X' = keep session if finished
    SELECTION-SCREEN END OF LINE.
    PARAMETERS:p_file LIKE rlgrap-filename.
    at selection screen *
    AT SELECTION-SCREEN.
    group and user must be filled for create session
    IF SESSION = 'X' AND
    GROUP = SPACE. "OR USER = SPACE.
    MESSAGE E613(MS).
    ENDIF.
    create batchinput session *
    FORM OPEN_GROUP.
    IF SESSION = 'X'.
    SKIP.
    WRITE: /(20) 'Create group'(I01), GROUP.
    SKIP.
    *----open batchinput group
    CALL FUNCTION 'BDC_OPEN_GROUP'
    EXPORTING
    CLIENT = SY-MANDT
    GROUP = GROUP
    USER = sy-uname.
    WRITE:/(30) 'BDC_OPEN_GROUP'(I02),
    (12) 'returncode:'(I05),
    SY-SUBRC.
    ENDIF.
    ENDFORM. "OPEN_GROUP
    end batchinput session *
    FORM CLOSE_GROUP.
    IF SESSION = 'X'.
    *------close batchinput group
    CALL FUNCTION 'BDC_CLOSE_GROUP'.
    WRITE: /(30) 'BDC_CLOSE_GROUP'(I04),
    (12) 'returncode:'(I05),
    SY-SUBRC.
    ELSE.
    IF E_GROUP_OPENED = 'X'.
    CALL FUNCTION 'BDC_CLOSE_GROUP'.
    WRITE: /.
    WRITE: /(30) 'Fehlermappe wurde erzeugt'(I06).
    ENDIF.
    ENDIF.
    ENDFORM. "CLOSE_GROUP
    Start new transaction according to parameters *
    FORM BDC_TRANSACTION USING TCODE TYPE ANY.
    DATA: L_SUBRC LIKE SY-SUBRC.
    *------batch input session
    IF SESSION = 'X'.
    CALL FUNCTION 'BDC_INSERT'
    EXPORTING
    TCODE = TCODE
    TABLES
    DYNPROTAB = it_BDCDATA.
    WRITE: / 'BDC_INSERT'(I03),
    TCODE,
    'returncode:'(I05),
    SY-SUBRC,
    'RECORD:',
    SY-INDEX.
    ELSE.
    REFRESH it_MESSTAB.
    CALL TRANSACTION TCODE USING it_BDCDATA
    MODE CTUMODE
    UPDATE CUPDATE
    MESSAGES INTO it_MESSTAB.
    L_SUBRC = SY-SUBRC.
    WRITE: / 'CALL_TRANSACTION',
    TCODE,
    'returncode:'(I05),
    L_SUBRC,
    'RECORD:',
    SY-INDEX.
    ENDIF.
    Message handling for Call Transaction *
    perform subr_mess_hand using g_mess.
    *-----Erzeugen fehlermappe
    IF L_SUBRC <> 0 AND E_GROUP <> SPACE.
    IF E_GROUP_OPENED = ' '.
    CALL FUNCTION 'BDC_OPEN_GROUP'
    EXPORTING
    CLIENT = SY-MANDT
    GROUP = E_GROUP
    USER = sy-uname
    KEEP = E_KEEP.
    E_GROUP_OPENED = 'X'.
    ENDIF.
    CALL FUNCTION 'BDC_INSERT'
    EXPORTING
    TCODE = TCODE
    TABLES
    DYNPROTAB = it_BDCDATA.
    ENDIF.
    REFRESH it_BDCDATA.
    ENDFORM. "BDC_TRANSACTION
    Form subr_bdc_table *
    text
    -->P_0220 text *
    -->P_0221 text *
    -->P_0222 text *
    FORM subr_bdc_table USING VALUE(P_0220) TYPE ANY
    VALUE(P_0221) TYPE ANY
    VALUE(P_0222) TYPE ANY.
    CLEAR it_bdcdata.
    IF P_0220 = ' '.
    CLEAR it_bdcdata.
    it_bdcdata-fnam = P_0221.
    it_bdcdata-fval = P_0222.
    APPEND it_bdcdata.
    ELSE.
    it_bdcdata-dynbegin = P_0220.
    it_bdcdata-program = P_0221.
    it_bdcdata-dynpro = P_0222.
    APPEND it_bdcdata.
    ENDIF.
    ENDFORM. " subr_bdc_table
    Form subr_mess_hand *
    text *
    -->P_G_MESS text *
    FORM subr_mess_hand USING P_G_MESS TYPE ANY.
    LOOP AT IT_MESSTAB.
    CALL FUNCTION 'FORMAT_MESSAGE'
    EXPORTING
    ID = it_messtab-msgid
    LANG = it_messtab-msgspra
    NO = it_messtab-msgnr
    v1 = it_messtab-msgv1
    v2 = it_messtab-msgv2
    IMPORTING
    MSG = P_G_MESS
    EXCEPTIONS
    OTHERS = 0.
    CASE it_messtab-msgtyp.
    when 'E'.
    it_error-error_rec = P_G_MESS.
    it_error-lifnr = it_me21-lifnr.
    it_error-tabix = v_count.
    APPEND IT_ERROR.
    when 'S'.
    it_sucess-sucess_rec = P_G_MESS.
    it_sucess-lifnr = it_me21-lifnr.
    it_sucess-tabix = v_count.
    APPEND IT_SUCESS.
    endcase.
    ENDLOOP.
    Describe table it_sucess lines v_ns.
    Describe table it_error lines v_ne.
    ENDFORM. " subr_mess_hand
    Regards
    Anji

Maybe you are looking for

  • Problem with data formatting​!

    Hi, I'm attaching the text file as well as vi. I'm basically getting all the data and storing it into the text file. When the for loop iterates for the first time, I store the frequency and mag from the analyser into text file. Next time when it iter

  • How to pull Data from SQL server in FDM

    Hi Experts How to pull the HFM data from One SQL server to Another SQL Server using integration scripts in FDQM? regards Dev

  • Will Linksys wireless routers be updated to the final 802.11n spec when its finished?

    Will Linksys wireless routers be updated to the final 802.11n spec when its finished? I read that most can be updated to the final spec with a firmware update.

  • Ipod got wet, now doing nutty things

    I found out when I friend borrowed my ipod, he MAY have gotten it wet. It was dead for a while, but I did a restore on it 5 times but still have the same problems. 1.Ipod icon appears on the desktop, then disappears..but does show up in Itunes. 2.Bat

  • Force specific language for google searchbox

    Hi, I'm in Poland but I'm connecting to the Internet using proxy located in Sweden Languages and locale is set to PL Now: when I use google searchbox using search engine it automatically moves query to google.se What can I do to force it to use googl