Application Development 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: 

BDC question

Former Member
0 Kudos

Hi,

I did a BDC recording for a transaction and I am going to use that in a userexit of a standard IDOC function module. I did all the steps like below in the userexit.

PERFORM bdc_dynpro TABLES bdcdata USING - - - - - - -- so and so..

PERFORM bdc_field TABLES bdcdata USING - - - - - - -- so and so..

PERFORM bdc_field TABLES bdcdata USING - - - - - - -- so and so..

PERFORM bdc_field TABLES bdcdata USING - - - - - - -- so and so..

PERFORM bdc_dynpro TABLES bdcdata USING - - - - - - -- so and so..

PERFORM bdc_field TABLES bdcdata USING 'BDC_OKCODE' '=SICH_T'.

Do I also have to call ''BDC_OPEN_GROUP' and 'BDC_CLOSE_GROUP' before and after the above codes. Is it mandatory? Also do I have to use FM 'BDC_INSERT' anwyere? The coding is working fine as of now even with out calling open group and close group but not sure if it will work in future too with out any errors.

Please give your input.

Thanks a lot!

1 ACCEPTED SOLUTION

ferry_lianto
Active Contributor
0 Kudos

Hi Krishen,

If you use BDC session method then you need to perform 'BDC_OPEN_GROUP', 'BDC_INSERT' and 'BDC_CLOSE_GROUP'.

If you use BDC call transaction then you don't need to perform above. BDC call transaction is the common one to use with IDoc processing.

Regards,

Ferry Lianto

6 REPLIES 6

former_member181962
Active Contributor
0 Kudos

Hi Krishen,

YOu should have a BDC_OPEN_GROUP compulsorily i norder to use BDC_INSERT. and also you should close the session that you are creating.

Are you able to view the session that you have created in sm35 after the transaction is being executed??

REgards,

Ravi

ferry_lianto
Active Contributor
0 Kudos

Hi Krishen,

If you use BDC session method then you need to perform 'BDC_OPEN_GROUP', 'BDC_INSERT' and 'BDC_CLOSE_GROUP'.

If you use BDC call transaction then you don't need to perform above. BDC call transaction is the common one to use with IDoc processing.

Regards,

Ferry Lianto

Former Member
0 Kudos

the code will work properly...

in case u have errors while posting the data, then u have to capture the error records. for that prpose we use call seesion methods so that the errors are captured and they can be executed using SM35.

first call open seesion method... now for every failure record move data to bdc_insert session. finally close the session. now u can display a message saying that goto SM35 and execute the seeion name to rectify the errors.

Former Member
0 Kudos

Hi,

If you want to do the BDC from SE38, then you need to call the BDC_OPEN_GROUP to open a Session then BDC_INSERT to insert the records,

but in your case, you are writing the code in that transaction only, then there is no need to open a session and run that session

Regards

Sudheer

Former Member
0 Kudos

Kishen,

You are getting confused between the 2 types of BDCs (Batch input and Call transaction). In the first you create a batch input session and in the other you don't. If you chose to create a batch input session you will have to process it separately using transaction SM35 (the data update happens only when the batch input session created is processed). Given your scenario call transaction (BDC without batch input session) is a better approach (where the call transaction statement will update the database records). You will not require ''BDC_OPEN_GROUP', 'BDC_CLOSE_GROUP' or 'BDC_INSERT'. These subroutines are used for creating batch input sessions.

Having said that you would require to determine how you want to handle the errors. Since this is an IDOC you are processing you can write the error message in the IDOC's status records. You will have to trap the messages in the message table of type BDCMSGCOLL. All the messages issued by the transaction (success, warning, information and error) are returned in this table. You will know what the usual success message is. First try looking for the success message in the message table. If the success message could not be found pick the first error message. You can then write it to the idoc status records.

DATA: t_messtab TYPE TABLE OF BDCMSGCOLL WITH HEADER LINE,

t_bdcdata TYPE TABLE OF BDCDATA WITH HEADER LINE.

  • Populate table t_bdcdata

REFRESH t_messtab.

CALL TRANSACTION <transaction number> USING t_bdcdata

MODE 'N'

UPDATE 'S'

MESSAGES INTO t_messtab.

1) Read table t_messtab for the usual success message.

2) If not found pick the first error message.

Field MSGTYP store the type of message returned in internal table t_messtab.

Hope this helps.

0 Kudos

Thanks so much Mark for your explanation. It really helped!