SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

BDC Template Program



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Batch Input (BDC), Background processing and Jobs
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1636

PostPosted: Wed Mar 04, 2009 5:03 pm    Post subject: BDC Template Program Reply with quote

Version 2.0
Author WATTO
Source from: http: /www.watto.org/program/abap/download/Z_BDC_TEMPLATE.abap

Description: A template program for building a report that generates and runs BDC commands, either directly or as a BDC session.

Code:
REPORT z_bdc_template.

* BDC data
DATA:
  i_bdc_data TYPE STANDARD TABLE OF bdcdata,
  v_bdc_data TYPE bdcdata.


*----------------------------------------------------------------------*
* START-OF-SELECTION
*----------------------------------------------------------------------*
START-OF-SELECTION.

  CLEAR:
    i_bdc_data,
    v_bdc_data.

  REFRESH:
    i_bdc_data.

  DATA:
    lv_use_call(1) TYPE c VALUE 'X'.

  DATA:
    lv_fmname(3) TYPE c VALUE 'BOB'.


  IF lv_use_call = 'X'.
*   Use the CALL TRANSACTION method

    PERFORM bdc_dynpro      USING 'SAPLSFUNCTION_BUILDER' '1008'.
    PERFORM bdc_field       USING 'BDC_CURSOR' 'RS38L-NAME'.
    PERFORM bdc_field       USING 'BDC_OKCODE' '=WB_EXEC'.
    PERFORM bdc_field       USING 'RS38L-NAME' lv_fmname.

    CALL TRANSACTION 'SE37' USING i_bdc_data MODE 'E'.

  ELSE.
*   Use the BDC_TRANSACTION method

    PERFORM bdc_open_group.

    PERFORM bdc_dynpro      USING 'SAPLSFUNCTION_BUILDER' '1008'.
    PERFORM bdc_field       USING 'BDC_CURSOR' 'RS38L-NAME'.
    PERFORM bdc_field       USING 'BDC_OKCODE' '=WB_EXEC'.
    PERFORM bdc_field       USING 'RS38L-NAME' lv_fmname.

    PERFORM bdc_transaction USING 'SE37'.

    PERFORM bdc_close_group.

  ENDIF.



*----------------------------------------------------------------------*
*     FORM bdc_open_group
*----------------------------------------------------------------------*
* [+] Opens a group for a BDC session
*----------------------------------------------------------------------*
FORM bdc_open_group.

  DATA:
    lv_group(12) TYPE c VALUE 'MY_GROUP'.

  CALL FUNCTION 'BDC_OPEN_GROUP'
    EXPORTING
      client   = sy-mandt
      group    = lv_group
      user     = sy-uname
      keep     = ' '
      holddate = sy-datum.

ENDFORM.                    "bdc_open_group


*----------------------------------------------------------------------*
*     FORM bdc_close_group
*----------------------------------------------------------------------*
* [+] Closes a BDC group
*----------------------------------------------------------------------*
FORM bdc_close_group.

  CALL FUNCTION 'BDC_CLOSE_GROUP'.

ENDFORM.                    "bdc_close_group


*----------------------------------------------------------------------*
*     FORM bdc_transaction
*----------------------------------------------------------------------*
* [+] Call a transaction in a BDC session
*----------------------------------------------------------------------*
FORM bdc_transaction USING tcode.

  CALL FUNCTION 'BDC_INSERT'
    EXPORTING
      tcode     = tcode
    TABLES
      dynprotab = i_bdc_data.

  REFRESH i_bdc_data.

ENDFORM.                    "bdc_transaction


*----------------------------------------------------------------------*
*     FORM bdc_dynpro
*----------------------------------------------------------------------*
* [+] Add a screen to a BDC session
*----------------------------------------------------------------------*
FORM bdc_dynpro USING program dynpro.
  CLEAR v_bdc_data.

  v_bdc_data-program  = program.
  v_bdc_data-dynpro   = dynpro.
  v_bdc_data-dynbegin = 'X'.
  APPEND v_bdc_data TO i_bdc_data.

ENDFORM.                    "bdc_dynpro


*----------------------------------------------------------------------*
*     FORM bdc_field
*----------------------------------------------------------------------*
* [+] Adds a value to a field on a screen, for a BDC session
*----------------------------------------------------------------------*
FORM bdc_field USING fnam fval.
  CLEAR v_bdc_data.

  v_bdc_data-fnam = fnam.
  v_bdc_data-fval = fval.
  APPEND v_bdc_data TO i_bdc_data.

ENDFORM.                    "bdc_field
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Batch Input (BDC), Background processing and Jobs All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.