Recording
With the recording function SAP automatically cazn genererate the BDC table.
- Find the transaction code for the screen that you wan't to record
- Open transaction SM35 - Batch Input
- Push the button Recording
- In the Recording screen, enter then name you want to give the recording, anmd push the Create button
- You will now be prompted for the transaction code. Enter the transaction code. Push the enter button. You are now in the screen where you enter the transactions.
- Enter transactions as normal, and leave the transaction when finished.
- You will now hen se an overview of the recording.
- Save the recording.
- Go back
- Push the Overview ( Mountain) button, to se the recording.
- You can know generate a program (push the Generate program button ) or create a session ( Push the Create session button ).
- If you have created a session, go back to the initial screen of SM35 and push the Overview button.
- Select your batch input session, and process it either in back- or foreground.
Example of program for Batch Input and Call Transaction
This example shows how to use Call Transaction. If Call Transaction fails,
a batch input session is created.
DATA: BEGIN OF BDC_TAB OCCURS 0.
INCLUDE STRUCTURE BDCDATA.
DATA: END OF BDC_TAB.
FORM Create_Transaction.
* Table for messages from call transaction. The table is automatically
* filled with messags from call transaction.
DATA BEGIN OF messtab OCCURS 10.
INCLUDE STRUCTURE bdcmsgcoll.
DATA END OF messtab.
REFRESH bdc_tab.
* Create new dynpro
PERFORM bdc_newdynpro USING 'SAPML03T' '101'.
* Insert fields
PERFORM bdc_field USING 'LTAK-BWLVS' w_screen1000-io_bwls.
PERFORM bdc_field USING 'LTAP-MATNR' w_screen1000-io_matnr.
PERFORM bdc_field USING 'RL03T-ANFME' w_tmpstr.
PERFORM bdc_field USING 'LTAP-CHARG' w_screen1000-io_charg.
PERFORM bdc_field USING 'BDC_OKCODE' '=TAM'.
................. And much more of the same ..................
**** Use this part if you want to use call transaction
* Call the transaction. Messages from Call Transaction are stored in the
* internal table messtab
CALL TRANSACTION 'LT01' USING bdc_tab MODE 'N' UPDATE 'S'
MESSAGES INTO messtab.
IF sy-subrc = 0.
* Call transaction successfull, get the number of the Transfer Order that
* was created
LOOP AT messtab.
IF messtab-dynumb = '0104' AND messtab-msgnr = '016'.
w_transportorderno = messtab-msgv1.
ENDIF.
ENDLOOP.
ELSE.
* Call transaction failed, create a batch input session instead.
PERFORM open_group.
PERFORM bdc_insert USING 'LT01'.
PERFORM close_group.
ENDIF.
ENDFORM.
Here are the strandard forms used for call transaction and batch input
*******************************************************************
* Starts a new screen
*******************************************************************
FORM bdc_newdynpro USING program dynpro.
CLEAR bdc_tab.
bdc_tab-program = program.
bdc_tab-dynpro = dynpro.
bdc_tab-dynbegin = 'X'.
APPEND bdc_tab.
ENDFORM.
*******************************************************************
* Inserts a field in bdc_tab
*******************************************************************
FORM bdc_field USING fnam fval.
CLEAR bdc_tab.
bdc_tab-fnam = fnam.
bdc_tab-fval = fval.
APPEND bdc_tab.
ENDFORM.
*******************************************************************
* Opens group
*******************************************************************
FORM open_group.
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
client = sy-mandt
* DEST = FILLER8
group = 'ZSM02'
* HOLDDATE = FILLER8
keep = 'X'
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.
ENDFORM.
*******************************************************************
* Closes group
*******************************************************************
FORM close_group.
CALL FUNCTION 'BDC_CLOSE_GROUP'
EXCEPTIONS
not_open = 1
queue_error = 2
OTHERS = 3.
ENDFORM.
*******************************************************************
* BDC_INSERT
*******************************************************************
FORM bdc_insert USING tcode.
CALL FUNCTION 'BDC_INSERT'
EXPORTING
tcode = tcode
* POST_LOCAL = NOVBLOCAL
* PRINTING = NOPRINT
TABLES
dynprotab = bdc_tab
EXCEPTIONS
internal_error = 1
not_open = 2
queue_error = 3
tcode_invalid = 4
printing_invalid = 5
posting_invalid = 6
OTHERS = 7.
ENDFORM.
No comments:
Post a Comment