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

BDC---Call transaction

Former Member
0 Likes
1,353

Hi

Can any of you give me a detailed program on BDC---call transaction methid including the transaction program,MPP program the structure and also the report program

With regards

Vijay

Hi

Can any of you give me a detailed program on BDC---call transaction methid including the transaction program,MPP program the structure and also the report program

With regards

Vijay

10 REPLIES 10
Read only

Former Member
0 Likes
1,291

Hi,

BDC CALL TRANSACTION METHOD:

-


Since we cannot modify the error record using direct input method, we go for call transaction method. Here, we create a screen to populate error records in input fields and from the screen, we can modify the error records and then insert into database table.

Steps to be followed in Call Transaction MEthod:

-


1. Analyze the flat file.

2. Create a screen for database table fields using MPP. Create a Transaction code for the screen.

3. Write the following code in SE38 editor:

DATA : BEGIN OF ITAB OCCURS 0,

STR(255),

END OF ITAB.

CALL FUNCTION 'UPLOAD'

EXPORTING

FILENAME = 'C:\KNA.TXT'

FILETYPE = 'ASC'

TABLES

DATA_TAB = ITAB.

DATA ITAB1 LIKE KNA1 OCCURS 0 WITH HEADER LINE.

DATA JTAB LIKE BDCDATA OCCURS 0 WITH HEADER LINE.

LOOP AT ITAB.

SPLIT ITAB-STR AT ',' INTO ITAB1-KUNNR ITAB1-NAME1 ITAB1-ORT01

ITAB1-LAND1.

APPEND ITAB1.

ENDLOOP.

LOOP AT ITAB1.

PERFORM PROGINFO USING 'SAPMZCALLTRANSACTION' '100'.

PERFORM FLDINFO USING 'KARTHIK-KUNNR' ITAB1-KUNNR.

PERFORM FLDINFO USING 'KARTHIK-NAME1' ITAB1-NAME1.

PERFORM FLDINFO USING 'KARTHIK-ORT01' ITAB1-ORT01.

PERFORM FLDINFO USING 'KARTHIK-LAND1' ITAB1-LAND1.

CALL TRANSACTION 'ZCALLTRANS' USING JTAB.

ENDLOOP.

FORM PROGINFO USING PROGNAME SCRNUM.

CLEAR JTAB.

REFRESH JTAB.

JTAB-PROGRAM = PROGNAME.

JTAB-DYNPRO = SCRNUM.

JTAB-DYNBEGIN = 'X'.

APPEND JTAB.

ENDFORM.

FORM FLDINFO USING FLDNAME FLDVALUE.

CLEAR JTAB.

JTAB-FNAM = FLDNAME.

JTAB-FVAL = FLDVALUE.

APPEND JTAB.

ENDFORM.

Save -> Activate -> Execute.

In the above code,

BDCDATA is a structure used to populate the internal table records into the screen fields. The BDCDATA structure has following components:

PROGRAM - Holds the name of MPP program where the screen is created.

DYNPRO - Holds the screen number where the internal fields to be populated.

DYNBEGIN - Used to initiate the screen when the program is executed. The default value to be specified is 'X'.

FNAM - Specifies input field name in the screen where the data is to be populated.

FVAL - Specifies from which internal table field, the data should be passed to the screen field.

'CALL TRANSACTION' statement is used to call the screen created to populate error records.

SYNTAX:

-


CALL TRANSACTION <Tcode> USING <BDCDATA_itab> MODE <mode> UPDATE <update>.

MODE: This is used to specify which mode to be followed when calling transaction. The types of mode are:

A - Display the screen.

E - Display only error records from the flat file.

N - Background processing.

UPDATE: This is used to specify the update task of records in the database table. The types of update tasks are:

A - Asynchronous update

S - Synchronous update

L - Local update

Advantages of CALL TRANSACTION:

-


Error records can be modified.

This method can be used in support projects.

Reward Points if found helpfull..

Cheers,

Chandra Sekhar.

Read only

0 Likes
1,291

Hi chandra sekhar

Can you plesse give me the MPP code for "ZCALLTRANS"

Vijay

Read only

Former Member
0 Likes
1,291

Hi Vijay,

You could try do a CALL TRANSACTION USING....

Something like this:

DATA BEGIN OF BDCDATA OCCURS 100.

INCLUDE STRUCTURE BDCDATA.

DATA END OF BDCDATA.

DATA BEGIN OF MESSTAB OCCURS 10.

INCLUDE STRUCTURE BDCMSGCOLL.

DATA END OF MESSTAB.

DATA REPORT(8).

BDCDATA-PROGRAM = '<program name>'.

BDCDATA-DYNPRO = '<screen number>'.

BDCDATA-DYNBEGIN = 'X'.

APPEND BDCDATA.

CLEAR BDCDATA.

BDCDATA-FNAM = fieldname.

BDCDATA-FVAL = fieldvalue.

APPEND BDCDATA.

...

....

CALL TRANSACTION 'F-51' USING BDCDATA MODE 'N'

MESSAGES INTO MESSTAB.

Hope it helps you !

Kindly Reward Points If You Found The Reply Helpful,

Cheers,

Chaitanya.

Read only

Former Member
0 Likes
1,291

Hi,

Try this and let me know the status.

DATA: BEGIN OF itab OCCURS 0,

str(255),

END OF itab.

DATA: BEGIN OF itab1 OCCURS 0,

lifnr LIKE lfa1-lifnr,

name1 LIKE lfa1-name1,

ort01 LIKE lfa1-ort01,

END OF itab1.

DATA: jtab LIKE bdcdata OCCURS 0 WITH HEADER LINE.

DATA: ktab TYPE TABLE OF bdcmsgcoll,

wa TYPE bdcmsgcoll.

CALL FUNCTION 'WS_UPLOAD'

EXPORTING

filename = 'D:\ABAP EVE\ffile4.txt'

filetype = 'ASC'

TABLES

data_tab = itab

EXCEPTIONS

conversion_error = 1

file_open_error = 2

file_read_error = 3

invalid_type = 4

no_batch = 5

unknown_error = 6

invalid_table_width = 7

gui_refuse_filetransfer = 8

customer_error = 9

no_authority = 10

OTHERS = 11.

IF sy-subrc <> 0.

WRITE:/ 'no file exist'.

ENDIF.

LOOP AT itab.

SPLIT itab-str AT ',' INTO itab1-lifnr itab1-name1 itab1-ort01.

APPEND itab1.

ENDLOOP.

LOOP AT itab1.

PERFORM prginfo USING 'SAPMZBDCCT' '123'.

PERFORM fldinfo USING 'i01' itab1-lifnr.

PERFORM fldinfo USING 'i02' itab1-name1.

PERFORM fldinfo USING 'i03' itab1-ort01.

CALL TRANSACTION 'ZCSBDCCT' USING jtab

MODE 'N'

MESSAGES INTO ktab.

ENDLOOP.

--- Display the Status messages ---

LOOP AT ktab INTO wa WHERE msgtyp = 'E'.

WRITE:/ wa.

ENDLOOP.

&----


*& Form prginfo

&----


  • text

----


  • -->PRGNAME text

  • -->SCRNUMBER text

----


FORM prginfo USING prgname scrnumber.

CLEAR jtab.

REFRESH jtab.

jtab-program = prgname.

jtab-dynpro = scrnumber.

jtab-dynbegin = 'X'.

APPEND jtab.

ENDFORM. "prginfo

&----


*& Form fldinfo

&----


  • text

----


  • -->FLDNM text

  • -->FLDVAL text

----


FORM fldinfo USING fldnm fldval.

CLEAR jtab.

jtab-fnam = fldnm.

jtab-fval = fldval.

APPEND jtab.

ENDFORM. "fldinfo

MPP CODE.

Create the MPP program and design the layout with 3 input fields.

TOP-INCLUDE.

DATA: OK_CODE TYPE SY-UCOMM.

DATA: I01(10),I02(20),I03(26).

DATA: WA TYPE LFA1.

PAI

CASE OK_CODE.

WHEN 'INSERT'.

MOVE I01 TO WA-LIFNR.

MOVE I02 TO WA-NAME1.

MOVE I03 TO WA-ORT01.

INSERT INTO LFA1 VALUES WA.

IF SY-SUBRC = 0.

MESSAGE I001(ZCSMSG).

ELSE.

MESSAGE I002(ZCSMSG).

ENDIF.

WHEN 'EXIT'.

LEAVE PROGRAM.

ENDCASE.

Flat file

200001,Yogesh,Hyderabad

220003,Wreline,Calfornia

321224,Alexme,Sandiago

Reward,if useful.

Thanks,

Chandu

Read only

0 Likes
1,291

Hi chandu

Just checking it my system is lil slow..will get back to u in a hour...thankss

Read only

0 Likes
1,291

Hi chandu

Used your code like below but am getting a runtime error

''SUBMIT WRONG_TYPE" exactly at the call transaction statement.please help

*&----


**& Report ZBDC_CT1

**&

*&----


**&

**&

*&----


*

REPORT ZBDC_CT1.

*DATA BEGIN OF BDCDATA OCCURS 100.

*INCLUDE STRUCTURE BDCDATA.

*DATA END OF BDCDATA.

*

*DATA BEGIN OF MESSTAB OCCURS 10.

*INCLUDE STRUCTURE BDCMSGCOLL.

*DATA END OF MESSTAB.

*

*DATA REPORT(8).

*

*BDCDATA-PROGRAM = '<program name>'.

*BDCDATA-DYNPRO = '<screen number>'.

*BDCDATA-DYNBEGIN = 'X'.

*APPEND BDCDATA.

*CLEAR BDCDATA.

*BDCDATA-FNAM = fieldname.

*BDCDATA-FVAL = fieldvalue.

*APPEND BDCDATA.

*

*CALL TRANSACTION 'F-51' USING BDCDATA MODE 'N'

*MESSAGES INTO MESSTAB.

DATA: BEGIN OF itab OCCURS 0,

str(255),

END OF itab.

DATA: BEGIN OF itab1 OCCURS 0,

lifnr LIKE lfa1-lifnr,

name1 LIKE lfa1-name1,

ort01 LIKE lfa1-ort01,

END OF itab1.

DATA: jtab LIKE bdcdata OCCURS 0 WITH HEADER LINE.

DATA: ktab TYPE TABLE OF bdcmsgcoll,

wa TYPE bdcmsgcoll.

CALL FUNCTION 'WS_UPLOAD'

EXPORTING

filename = 'C:\NEW.txt'

filetype = 'ASC'

TABLES

data_tab = itab

EXCEPTIONS

conversion_error = 1

file_open_error = 2

file_read_error = 3

invalid_type = 4

no_batch = 5

unknown_error = 6

invalid_table_width = 7

gui_refuse_filetransfer = 8

customer_error = 9

no_authority = 10

OTHERS = 11.

IF sy-subrc eq 0.

WRITE:/ 'no file exist'.

ENDIF.

LOOP AT itab.

SPLIT itab-str AT ',' INTO itab1-lifnr itab1-name1 itab1-ort01.

APPEND itab1.

ENDLOOP.

LOOP AT itab1.

PERFORM prginfo USING 'SAPMZSDN' '123'.

PERFORM fldinfo USING 'i01' itab1-lifnr.

PERFORM fldinfo USING 'i02' itab1-name1.

PERFORM fldinfo USING 'i03' itab1-ort01.

CALL TRANSACTION 'ZSDN' USING jtab

MODE 'N'

MESSAGES INTO ktab.

ENDLOOP.

*--- Display the Status messages ---

LOOP AT ktab INTO wa WHERE msgtyp = 'E'.

WRITE:/ wa.

ENDLOOP.

*&----


**& Form prginfo

*&----


*

*text

*----


*

*-->PRGNAME text

*-->SCRNUMBER text

*----


FORM prginfo USING prgname scrnumber.

CLEAR jtab.

REFRESH jtab.

jtab-program = prgname.

jtab-dynpro = scrnumber.

jtab-dynbegin = 'X'.

APPEND jtab.

ENDFORM. "prginfo

*&----


**& Form fldinfo

*&----


*

*text

*----


*

*-->FLDNM text

*-->FLDVAL text

*----


FORM fldinfo USING fldnm fldval.

CLEAR jtab.

jtab-fnam = fldnm.

jtab-fval = fldval.

APPEND jtab.

ENDFORM. "fldinfo

Read only

0 Likes
1,291

Hi,

It was successfully executed.

I didn't get any type of errors when i run my TCode.

Just paste this code and place the flat file in required path.

If possible try to debug.

Let me know wt happens exactly.

Regards,

Chandu

Read only

0 Likes
1,291

Hi chandu

It is executing succesfully...but atthe bottom of the screen am getting this error.One more doubt in the input field am creating in the properties of the input field am giving the NAME as IO1 and the TEXT as blank...Is that right?The output am getting is file does not exist and below the SUBMIT_WRONG_TYPE

Vijay

Read only

0 Likes
1,291

Hi,

No problem,if you give the text,then it will take as default value.

No need to give the Text value.

Reward,if useful.

Thanks,

Chandu

Read only

Former Member
0 Likes
1,291

Hi,

For BDC Prgm, after you doing recording click on the recording and then import to the prgm there in that prgm you can find 1 include bdcrec1. click on that include you will find the code for both session and call transaction.

Regards,

Sindhu