Application Development and Automation 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: 
Read only

upload data using bdc session method

Former Member
0 Likes
970

plz help me out that hw can i upload material using bdc session method if their is blank field named kzsel .what r the steps plz forward complete screen shots .

2 REPLIES 2
Read only

Former Member
0 Likes
648

Hi

Hope it will help you.

Reward if help.

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.

WT IS CALL TRANSACTION METHOD? WT IS SYNTAX/PROCEDURE?

CALL TRANSACTION :

1. It is compatible for small amount of data only.

2. It process the data Synchronously. i.e., The data is updated

at the time of execution.

3. It updates data both Synchronously and Asynchronously. When

we use Synchronous mode, it always verify all the data updated

successfully in the database.

When we use Asynchronous mode, the system can not wait till

all the data updated in the database.

4. It can handle only one application at a time.

5. It does not have Log file, we need to design logfile explicitly

using BDCMSGCOLL stucture.

Syntax :

CALL TRANSACTION <T.Code> USING <BDCTAB> MODE <A/N/E> UPDATE <S/A>

MESSAGES INTO <BDCMSGCOLL Int.Table>

Parameter 1 : Transaction Code

Parameter 2 : It is name of BDCDATA table.

Parameter 3 : Specifying Mode in which you execute transaction.

A - All screen mode. All the screen of transaction

are displayed.

N - No screen mode. No screen is displayed when you

execute the transaction.

E - Error screen. Only those screens are displayed

where you have error record.

Parameter 4 : Specifying Update type by which data base table is

updated.

S - It is for Synchronous update in which if you

change data for one table then all the relacted

tables gets updated. And then sy-subrc is returned

i.e., sy-subrc is returned for once and all.

A - It is for Asynchronous update, when you change

data of one table, the sy-subrc is returned. And

then updation of other affected tables takes place

If system fails to update other tables still

sy-subrc returned is 0.

Parameter 5 : When you update database table, operation is either

successful or unsuccessful or operation is successful

with some warning. These messages are stored in

internal table which you specify along with MESSAGE

statement. This internal table should be declared like

BDCMSGCOLL structure.

Steps for CALL TRANSACTION Method :

1. Interanal table for the data (structure similler to local file)

2. BDCTAB like BDCDATA.

3. Use UPLOAD/WS_UPLOAD/GUI_UPLOAD or DATASETS for upload data from

local file to internal table (i.e. ITAB).

4. LOOP at Itab.

Populate BDCTAB table.

CALL TRANSACTION <T.Code> USING <BDCTAB> MODE <A/N/E>

UPDATE <S/A> MESSAGES INTO <BDCMSGCOLL Int.Table>

Refresh BDCTAB.

ENDLOOP.

Read only

GauthamV
Active Contributor
0 Likes
648

hi,

check the sample code for creating material using bdc session method for mm01 transaction.

kzsel is nothing but selection indicator ,pass it as X if u want to use it.

reward points if hlpful.

report ZBDC_MM01

no standard page heading line-size 255.

data: it_bdcdata type standard table of bdcdata with header line.

data: begin of it_mm01 occurs 0,

mbrsh(1) type c,

mtart(4) type c,

werks(4) type c,

maktx(40) type c,

meins(3) type c,

matkl(9) type c,

bklas(4) type c,

end of it_mm01.

DATA : W_FILE TYPE STRING.

SELECTION-SCREEN BEGIN OF BLOCK 1 WITH FRAME TITLE TEXT-001.

PARAMETERs : filename LIKE RLGRAP-FILENAME.

SELECTION-SCREEN END OF BLOCK 1.

      • ACCEPTING THE FILE FROM USER **************

AT SELECTION-SCREEN ON VALUE-REQUEST FOR filename.

CALL FUNCTION 'F4_FILENAME'

EXPORTING

PROGRAM_NAME = SYST-CPROG

DYNPRO_NUMBER = SYST-DYNNR

FIELD_NAME = ' '

IMPORTING

FILE_NAME = filename.

.

START-OF-SELECTION.

************UPLOADING THE FILE *****************************

START-OF-SELECTION.

W_FILE = filename.

*CALLING THE FUNC GUI_UPLAOD TO COPY THE DATA FROM FLAT FILE TO

  • INTERNAL TABLE

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = W_FILE

FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = 'X'

tables

data_tab = it_mm01.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

*************Creaton the BDC_Open_Group************

CALL FUNCTION 'BDC_OPEN_GROUP'

EXPORTING

CLIENT = SY-MANDT

GROUP = 'ZMM01'

KEEP = 'X'

USER = SY-UNAME.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

*include bdcrecx1.

start-of-selection.

*perform open_group.

                                          • Creation the Fill_Data ****************

loop at it_mm01.

refresh it_bdcdata.

clear it_bdcdata.

perform bdc_dynpro using 'SAPLMGMM' '0060'.

perform bdc_field using 'BDC_CURSOR'

'RMMG1-MTART'.

perform bdc_field using 'BDC_OKCODE'

'=ENTR'.

perform bdc_field using 'RMMG1-MBRSH'

it_mm01-mbrsh.

perform bdc_field using 'RMMG1-MTART'

it_mm01-mtart.

perform bdc_dynpro using 'SAPLMGMM' '0070'.

perform bdc_field using 'BDC_CURSOR'

'MSICHTAUSW-DYTXT(09)'.

perform bdc_field using 'BDC_OKCODE'

'=ENTR'.

perform bdc_field using 'MSICHTAUSW-KZSEL(01)'

'X'.

perform bdc_field using 'MSICHTAUSW-KZSEL(02)'

'X'.

perform bdc_field using 'MSICHTAUSW-KZSEL(09)'

'X'.

perform bdc_dynpro using 'SAPLMGMM' '0080'.

perform bdc_field using 'BDC_CURSOR'

'RMMG1-WERKS'.

perform bdc_field using 'BDC_OKCODE'

'=ENTR'.

perform bdc_field using 'RMMG1-WERKS'

it_mm01-werks.

perform bdc_dynpro using 'SAPLMGMM' '4004'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'MAKT-MAKTX'

it_mm01-maktx.

perform bdc_field using 'BDC_CURSOR'

'MARA-MATKL'.

perform bdc_field using 'MARA-MEINS'

it_mm01-meins.

perform bdc_field using 'MARA-MATKL'

it_mm01-matkl.

perform bdc_dynpro using 'SAPLMGMM' '4004'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'BDC_CURSOR'

'MAKT-MAKTX'.

perform bdc_field using 'MAKT-MAKTX'

it_mm01-maktx.

perform bdc_dynpro using 'SAPLMGMM' '4000'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'MAKT-MAKTX'

it_mm01-maktx.

perform bdc_field using 'MARA-MEINS'

'EA'.

perform bdc_field using 'BDC_CURSOR'

'MBEW-BKLAS'.

perform bdc_field using 'MBEW-BKLAS'

it_mm01-bklas.

perform bdc_field using 'MBEW-VPRSV'

'V'.

perform bdc_field using 'MBEW-PEINH'

'1'.

perform bdc_dynpro using 'SAPLSPO1' '0300'.

perform bdc_field using 'BDC_OKCODE'

'=YES'.

CALL FUNCTION 'BDC_INSERT'

EXPORTING

TCODE = 'MM01'

  • POST_LOCAL = NOVBLOCAL

  • PRINTING = NOPRINT

  • SIMUBATCH = ' '

  • CTUPARAMS = ' '

TABLES

dynprotab = IT_BDCDATA.

.

IF sy-subrc = 0.

message 'sesion created' type 'S'.

ENDIF.

endloop.

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.

----


  • Start new screen *

----


FORM BDC_DYNPRO USING PROGRAM DYNPRO.

CLEAR IT_BDCDATA.

IT_BDCDATA-PROGRAM = PROGRAM.

IT_BDCDATA-DYNPRO = DYNPRO.

IT_BDCDATA-DYNBEGIN = 'X'.

APPEND IT_BDCDATA.

ENDFORM.

----


  • Insert field *

----


FORM BDC_FIELD USING FNAM FVAL.

  • IF FVAL <> NODATA.

CLEAR IT_BDCDATA.

IT_BDCDATA-FNAM = FNAM.

IT_BDCDATA-FVAL = FVAL.

APPEND IT_BDCDATA.

  • ENDIF.

ENDFORM.