Shared Top Border

Enterprise Resource
Planning Portal

 

Advertise | Founder BLOG

ERPGenie.COM ABAP Tips and Tricks Database

THE ultimate
ERP website

 

Forums | Vote for us |

Google    Other Search Options

Login

Login to view more content!!!





Lost Password?
No account yet? Register

Registered Access

Poll

What area of ABAP are you interested in?
 
Home arrow Tips and Tricks arrow General arrow General Flow of a BDC Program
General Flow of a BDC Program PDF Print E-mail
User Rating: / 0
PoorBest 
Written by Tejas   
Monday, 14 May 2007

General flow of a BDC program is like this....

1) First create recording for the T code which you want to make BDC for... Use T code SHDB for recording.

2 ) Now save that recording and create pogram from that recording using Create Program button. give the BDC driver program name and create.

3 ) Now the general logic of BDC program goes like this....

 - Upload Flat file into and internal table using function module "UPLOAD"
 - OPEN BDC GROUP.
 - Now loop at that internal table which contains the data from flat file.
 - move data from internal table to fields of BDCDATA using automatically gebnerated code from BDC.
 - CALL TRANSACTION <T CODE> using BDCDATA...
 - CLOSE BDC GROUP

A sample program for the same is attatched here for your referance... just go through it..


report ztej_test_new no standard page heading line-size 255.

data bdcdata like bdcdata occurs 0 with header line.
tables: zipcldesigcat.

data : begin of itab occurs 0,
        mandt like zipcldesigcat-mandt,
        zdesigncd like zipcldesigcat-zdesigncd,
        zdesignation like zipcldesigcat-zdesignation,
        zdesigcat like zipcldesigcat-zdesigcat,
       end of itab.

*INCLUDE bdcrecx1.

start-of-selection.
  perform upload.
  perform open.

  loop at itab.
    perform move.
    call transaction 'SE16' using bdcdata mode 'E'.
    refresh bdcdata.
  endloop.
  perform close.

*&---------------------------------------------------------------------*
*&      Form  UPLOAD
*&---------------------------------------------------------------------*
form upload.
  call function 'UPLOAD'
      exporting
*         CODEPAGE                = ''
           filename                = ''
           filetype                = 'DAT'
           item                    = 'Your File'
*         FILEMASK_MASK           = ' '
*         FILEMASK_TEXT           = ' '
*         FILETYPE_NO_CHANGE      = ' '
*         FILEMASK_ALL            = ' '
*         FILETYPE_NO_SHOW        = ' '
*         LINE_EXIT               = ' '
*         USER_FORM               = ' '
*         USER_PROG               = ' '
*         SILENT                  = 'S'
*    IMPORTING
*         FILESIZE                =
*         CANCEL                  =
*         ACT_FILENAME            =
*         ACT_FILETYPE            =
       tables
            data_tab                = itab
      exceptions
           conversion_error        = 1
           invalid_table_width     = 2
           invalid_type            = 3
           no_batch                = 4
           unknown_error           = 5
           gui_refuse_filetransfer = 6
           others                  = 7
            .
  if sy-subrc <> 0.
    message id sy-msgid type sy-msgty number sy-msgno
            with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  endif.

*CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
*     EXPORTING
*          filename                = 'C:\TEST.XLS'
*          i_begin_col             = 1
*          i_begin_row             = 1
*          i_end_col               = 3
*          i_end_row               = 5
*     tables
*          intern                  = ITAB
*    EXCEPTIONS
*         INCONSISTENT_PARAMETERS = 1
*         UPLOAD_OLE              = 2
*         OTHERS                  = 3
*          .
*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.                    " UPLOAD
*----------------------------------------------------------------------*
*        Start new screen                                              *
*----------------------------------------------------------------------*
form bdc_dynpro using program dynpro.
  clear bdcdata.
  bdcdata-program  = program.
  bdcdata-dynpro   = dynpro.
  bdcdata-dynbegin = 'X'.
  append bdcdata.
endform.

*----------------------------------------------------------------------*
*        Insert field                                                  *
*----------------------------------------------------------------------*
form bdc_field using fnam fval.
  if fval <> space.
    clear bdcdata.
    bdcdata-fnam = fnam.
    bdcdata-fval = fval.
    append bdcdata.
  endif.
endform.
*&---------------------------------------------------------------------*
*&      Form  OPEN
*&---------------------------------------------------------------------*
form open.
  call function 'BDC_OPEN_GROUP'
      exporting
           client              = sy-mandt
*         DEST                = FILLER8
           group               = 'ZDESIGCAT_R'
*         HOLDDATE            = FILLER8
*         KEEP                = FILLER1
           user                = sy-uname
*         RECORD              = FILLER1
*    IMPORTING
*         QID                 =
      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 <> 0.
    message id sy-msgid type sy-msgty number sy-msgno
            with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  endif.

endform.                    " OPEN

*&---------------------------------------------------------------------*
*&      Form  MOVE
*&---------------------------------------------------------------------*
form move.

perform bdc_dynpro      using 'SAPLSETB' '0230'.
perform bdc_field       using 'BDC_CURSOR'
                              'DATABROWSE-TABLENAME'.
perform bdc_field       using 'BDC_OKCODE'
                              '=ANLE'.
perform bdc_field       using 'DATABROWSE-TABLENAME'
                              'ZIPCLDESIGCAT'.
perform bdc_dynpro      using 'SAPLZIPCLDESIGCAT' '0001'.
perform bdc_field       using 'BDC_CURSOR'
                              'VIM_POSITION_INFO'.
perform bdc_field       using 'BDC_OKCODE'
                              '=NEWL'.
perform bdc_dynpro      using 'SAPLZIPCLDESIGCAT' '0001'.
perform bdc_field       using 'BDC_CURSOR'
                              'ZIPCLDESIGCAT-ZDESIGCAT(01)'.
perform bdc_field       using 'BDC_OKCODE'
                              '=SAVE'.
perform bdc_field       using 'ZIPCLDESIGCAT-ZDESIGNCD(01)'
                              '2101'.
perform bdc_field       using 'ZIPCLDESIGCAT-ZDESIGNATION(01)'
                              'new'.
perform bdc_field       using 'ZIPCLDESIGCAT-ZDESIGCAT(01)'
                              'n'.
perform bdc_dynpro      using 'SAPLZIPCLDESIGCAT' '0001'.
perform bdc_field       using 'BDC_CURSOR'
                              'ZIPCLDESIGCAT-ZDESIGNCD(02)'.
perform bdc_field       using 'BDC_OKCODE'
                              '=ENDE'.
perform bdc_dynpro      using 'SAPLSETB' '0230'.
perform bdc_field       using 'BDC_OKCODE'
                              '/EEND'.
perform bdc_field       using 'BDC_CURSOR'
                              'DATABROWSE-TABLENAME'.


endform.                    " MOVE

*&---------------------------------------------------------------------*
*&      Form  CLOSE
*&---------------------------------------------------------------------*
Form close.
  call function 'BDC_CLOSE_GROUP'
       exceptions
            not_open    = 1
            queue_error = 2
            others      = 3.
  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.                    " CLOSE

Related Items:

 
< Prev   Next >

Google Search

Statistics

Contribution Activity
Utilities: 38
Tips and Tricks: 333
Sample Code: 164
Total Contributions: 550

Member Activity
Members: 6175 since 2/1/2007!
New: 6 since yesterday!
Visitors: 1008714
We have 2 guests online

Newest Members

Welcome our newest members:

Google Ads

Shared Bottom Border

Contact Us | Polls | Add URL | Contribute | Privacy | Terms | Feedback

Discussion Forum | BLOG | Consultants: Post your resume | Companies: Advertise on ERPGenie.COM | Post Job
Financials Consultant | Consultant Review | Gallia Consulting | Supply Chain Project | SAP Financials Forum
GenieHoldings.COM, Inc. | Genie Press | WorkflowGenie | ESAGenie | ERPTopSites | ABAP Tips and Tricks | SAP Solutions Database

EDIGenie | Searching Survivor