Vous êtes sur la page 1sur 16

Transaction code SHDB is used for batch Input Recorder (Transaction Recorder) to record a series of transactions and their

screens. It mainly used for


Data transfer programs that use batch input or CALL TRANSACTION Batch input sessions Test data Function modules.

Steps to create a transaction recording 1. 2. 3. 4. 5. 6. 7. 8. Enter the transaction code SHDB. Enter a name for recording. Choose create button Enter the transaction code which we want to record Choose Continue Execute the transaction Choose Get Transaction if no errors occurred Choose next Transaction if we want to record any other transactions also. And continue the steps from 4 9. Save after the recording finished Steps to process a recorded transaction 1. 2. 3. 4. 5. 6. 7. Enter the transaction code SHDB Choose Overview Point your mouse to the corresponding recording Choose execute Enter the processing mode (A , E or N) Enter the update mode (A, S or L ) Press Enter

*************************************************************************************

Step1

Step2:

Continue

Select basic data1

Select tick mark and Enter material desc and unit of mesure

Click on yes button

Click on save button, and back button

Select program

Select tick mark Enter title and click on source code.

Click on local object

SESSION METHOD: ---------------

- It is one of the BDC techniques for uploading legacy data into SAP - The data is transferring from the internal table to database table through sessions. - Data along with its action is stored in session. - When the program has finished generating the session, you can run the session to execute the transaction. - Unless session is processed, the data is not transferred to database tables.

- The following Function Modules are used in the session method.

1. BDC_OPEN_GROUP (Used to create the session) Import Parameters : USER - User Name CLIENT - Client GROUP - Name of the session HOLD - The date when you want to process the session KEEP - X retain session even after processing it ' ' - Delete the session after processing.

2. BDC_INSERT (Data is transferred to session) Import Parameters :

TCODE - Transaction code DYNPROTAB BDCDATA table

3. BDC_CLOSE_GROUP (Used to close a session)

- Processing Steps

1. Generate the batch input session using function module BDC_OPEN_GROUP. 2. The proceed as follows for each transaction that the session contains: a. In the BDCDATA structure, enter the value for all screens and fields that must be processed in the transaction. b. Use BDC_INSERT to transfer the transaction and the BDCDATA structure to the session. 3. Close the batch input session with BDC_CLOSE_GROUP. 4. Start to process the generated session in T.Code SM35.

*&---------------------------------------------------------------------* *& SELECTION-SCREEN

*&---------------------------------------------------------------------* SELECTION-SCREEN BEGIN OF BLOCK bk1 WITH FRAME TITLE text-001. PARAMETERS : p_fname TYPE localfile. SELECTION-SCREEN END OF BLOCK bk1.

*&---------------------------------------------------------------------* *& TYPES

*&---------------------------------------------------------------------* * Type declaration for Customer data

TYPES: BEGIN OF t_mat, matnr type mara-matnr, mbrsh type mara-mbrsh, mtart type mara-mtart, maktx type MAKT-maktx, meins type mara-meins, END OF t_mat.

*&---------------------------------------------------------------------* *& DATA

*&---------------------------------------------------------------------* DATA: v_fname TYPE string,

Internal Table Declaration for Customer data i_mat TYPE STANDARD TABLE OF t_mat, wa_mat TYPE t_mat,

Internal Table Declaration for BDCDATA wa_bdcdata TYPE bdcdata,

i_bdcdata TYPE STANDARD TABLE OF bdcdata.

*&---------------------------------------------------------------------* *& AT SELECTION SCREEN

*&---------------------------------------------------------------------* AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_fname. * F4 functionality for File Name CALL FUNCTION 'F4_FILENAME' EXPORTING program_name = syst-cprog dynpro_number = syst-dynnr field_name = ' ' IMPORTING file_name = p_fname.

start-of-selection.

v_fname = p_fname.

* Upload data from flat file and store it in an Internal table CALL FUNCTION 'GUI_UPLOAD' EXPORTING filename filetype = v_fname = 'ASC'

has_field_separator = 'X' read_by_line TABLES data_tab = i_MAT. = 'X'

CALL FUNCTION 'BDC_OPEN_GROUP' EXPORTING client group keep user EXCEPTIONS client_invalid =1 = sy-mandt = 'ZCUST' = 'X' = sy-uname

destination_invalid = 2 group_invalid group_is_locked =3 =4

holddate_invalid = 5 internal_error queue_error running =6 =7 =8

system_lock_error = 9 user_invalid OTHERS = 10 = 11.

IF sy-subrc <> 0. MESSAGE e000(zmsg) WITH 'Error while opening the session'. ENDIF. LOOP AT i_mat INTO wa_mat. CLEAR wa_bdcdata. REFRESH i_bdcdata[].

perform bdc_dynpro perform bdc_field

using 'SAPLMGMM' '0060'. using 'BDC_CURSOR'

'RMMG1-MATNR'. perform bdc_field using 'BDC_OKCODE'

'=ENTR'. perform bdc_field using 'RMMG1-MATNR'

wa_mat-matnr. perform bdc_field using 'RMMG1-MBRSH'

wa_mat-mbrsh. perform bdc_field using 'RMMG1-MTART'

wa_mat-mtart. perform bdc_dynpro perform bdc_field using 'SAPLMGMM' '0070'. using 'BDC_CURSOR'

'MSICHTAUSW-DYTXT(01)'. perform bdc_field using 'BDC_OKCODE'

'=ENTR'. perform bdc_field 'X'. using 'MSICHTAUSW-KZSEL(01)'

perform bdc_dynpro perform bdc_field '/00'. perform bdc_field

using 'SAPLMGMM' '4004'. using 'BDC_OKCODE'

using 'MAKT-MAKTX'

wa_mat-maktx. perform bdc_field using 'BDC_CURSOR'

'MARA-MEINS'. perform bdc_field using 'MARA-MEINS'

wa_mat-meins. perform bdc_dynpro perform bdc_field using 'SAPLSPO1' '0300'. using 'BDC_CURSOR'

'SPOP-OPTION1'. perform bdc_field using 'BDC_OKCODE'

'=YES'.

CALL FUNCTION 'BDC_INSERT' EXPORTING tcode TABLES dynprotab EXCEPTIONS internal_error = 1 not_open queue_error =2 =3 = i_bdcdata[] = 'MM01'

tcode_invalid = 4

printing_invalid = 5 posting_invalid = 6 OTHERS ENDLOOP. = 7.

CALL FUNCTION 'BDC_CLOSE_GROUP' EXCEPTIONS not_open = 1 queue_error = 2 OTHERS = 3.

*&--------------------------------------------------------------------* *& Form BDC_DYNPRO New Screen

*&--------------------------------------------------------------------* 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 i_bdcdata. ENDFORM. "BDC_DYNPRO

*----------------------------------------------------------------------* * Insert field *

*----------------------------------------------------------------------* FORM bdc_field USING fnam fval. IF fval <> space. CLEAR wa_bdcdata. wa_bdcdata-fnam = fnam. wa_bdcdata-fval = fval. APPEND wa_bdcdata TO i_bdcdata. ENDIF. ENDFORM. "BDC_FIELD

*****file******

MAT10 M

FERT

DESCP1 KG

Vous aimerez peut-être aussi