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

BDC-recording, only 1 entries captured, multiple selection of select option

former_member381412
Participant
0 Kudos

Dear All,

We have create a BDC for Z Tcode for multiple line item. one item updated successfully. after update one line item then BDC not working. if am entry /N then BDC update next line time. please check below Source code and give me idea.


report Z_ZPP005_AMB

    no standard page heading line-size 255.
TYPE-POOLS: SOI,TRUXS.
TYPES: BEGIN OF TY_ZNDEF_TAB,

       TRMB     TYPE ZNDEF_TAB-TRMB,
       ORDERNO  TYPE ZNDEF_TAB-ORDERNO,
       STATUS   TYPE ZNDEF_TAB-STATUS,
  END OF TY_ZNDEF_TAB.

DATA: IT_RAW TYPE TRUXS_T_TEXT_DATA.
DATA : IT_ZNDEF_TAB TYPE TABLE OF TY_ZNDEF_TAB,
       WA_ZNDEF_TAB TYPE TY_ZNDEF_TAB.


DATA : IT_BDCDATA TYPE TABLE OF BDCDATA,
       WA_BDCDATA TYPE BDCDATA.
DATA : IT_BDCMSG TYPE TABLE OF BDCMSGCOLL,
       WA_BDCMSG TYPE BDCMSGCOLL.

PARAMETERS : P_FILE TYPE LOCALFILE.


AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
 

 CALL FUNCTION 'F4_FILENAME'

   EXPORTING
     PROGRAM_NAME        = SYST-CPROG
     DYNPRO_NUMBER       = SYST-DYNNR
     FIELD_NAME          = ' '
   IMPORTING
     FILE_NAME           = P_FILE.            

START-OF-SELECTION.

DATA: L_FILE TYPE STRING.
      L_FILE = P_FILE.

      CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'

        EXPORTING
*         I_FIELD_SEPERATOR          =
         I_LINE_HEADER              = 'X'
          I_TAB_RAW_DATA             = IT_RAW
          I_FILENAME                 = P_FILE
        TABLES
          I_TAB_CONVERTED_DATA       = IT_ZNDEF_TAB
*       EXCEPTIONS
*         CONVERSION_FAILED          = 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.
LOOP AT IT_ZNDEF_TAB INTO WA_ZNDEF_TAB.
CLEAR WA_BDCDATA.
REFRESH IT_BDCDATA.

*perform open_group.

perform bdc_dynpro      using 'ZRND_STS_CNG' '1000'.
perform bdc_field       using 'BDC_CURSOR'
                              'P_TRMB'.
perform bdc_field       using 'BDC_OKCODE'
                              '=ONLI'.
perform bdc_field       using 'P_TRMB'
                              WA_ZNDEF_TAB-TRMB.
perform bdc_dynpro      using 'ZRND_STS_CNG' '9000'.
perform bdc_field       using 'BDC_CURSOR'
                              'G_STATUS'.
perform bdc_field       using 'BDC_OKCODE'
                              '=BTTN_SAVE'.
perform bdc_field       using 'G_ORDERNO'
                              WA_ZNDEF_TAB-ORDERNO.
perform bdc_field       using 'G_STATUS'
                              WA_ZNDEF_TAB-STATUS.
*perform bdc_transaction using 'ZPP005'.
*perform close_group.

CALL TRANSACTION 'ZPP005' USING IT_BDCDATA MODE 'A' UPDATE 'A' MESSAGES INTO IT_BDCMSG.

IF SY-SUBRC = 0.
  WRITE:/ WA_ZNDEF_TAB-TRMB, 'SUBMITTED TO BDC'.
  ENDIF.
  ENDLOOP.
**************************************************************
*       FORM BDC_DYNPRO
**************************************************************

FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR WA_BDCDATA.
      WA_BDCDATA-PROGRAM = PROGRAM.
      WA_BDCDATA-DYNPRO  = DYNPRO.
      WA_BDCDATA-DYNBEGIN = 'X'.
APPEND WA_BDCDATA TO IT_BDCDATA.
ENDFORM.
***************************************************************
*      FORM BDC_FIELD
***************************************************************

FORM BDC_FIELD USING FNAM FVAL.
  CLEAR WA_BDCDATA.
  WA_BDCDATA-FNAM = FNAM.
  WA_BDCDATA-FVAL = FVAL.
APPEND WA_BDCDATA TO IT_BDCDATA.
ENDFORM.
3 REPLIES 3

raymond_giuseppi
Active Contributor
0 Kudos

We can hardly guess behavior of a customer (z namespace) program/report (dynpro 1000?)

Nevertheless, did you execute SHDB again, you may require a last function code to leave transaction (an EXIT code after BTTN_SAVE?) if (example) the program doesn't execute any COMMIT WORK to explicitly end transaction or if some dynpro next screen is the same dynpro, preventing effective BDC call.

0 Kudos

Dear Raymond Giuseppi,

Please guide how to use commit work in our program

0 Kudos

How did you update the database in your program, did you leave the job to SAP (and were lucky til there) or did you explicitly commit the changes of database with a call of FM DB_COMMIT or a statement such as COMMIT WORK (which would trigger a DB commit)

You should look for and read some documentation(s) such as the SAP transaction concept (Update Techniques) - or, if in a hurry and/or not curious, just add a COMMIT WORK statement at end of your open-sql statements...