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_INSERT for VK11

former_member1379176
Participant
0 Kudos
524

Hi all,

I am trying to set up a bdc session for entering pricing conditions through vk11. I recorded a session of the transaction using tcode SHDB to set up the bdc table with the parameters needed to complete the transaction, but it is not saving when I pass it to BDC_INSERT. Essentially the logic looks like this...

BDC_OPEN_GROUP

LOOP at itab into wa.

build bdc_tab using program, dynopro, dynbegin and fname from transaction SHDB recording with corresponding wa-fval 

BDC_INSERT

COMIT WORK every 100 records

ENDLOOP

BDC_CLOSE_GROUP

From the SHDB recording the first line in the display is

program = ' '

dynpro = ' '

dynbegin = 'T'

fname = 'VK11'

fval = ' '

If I include this line in the bdc_tab i get an eror of screen ' ' is invalid, but if i don't the session completes with no errors but does not save to the db tables. The recording that it is modeled after worked successfully, so I'm not sure why it won't save when running in the program bdc session with the exact same parameters. This is the fisrt bdc I have ever set up so I'm not sure what all I need to check. Any help is appreciated

Zack

1 ACCEPTED SOLUTION

Azeemquadri
Contributor
0 Kudos
208

Yes the blank values are special.

You need to refresh bdctab for every loop pass.

The first line without dynpro is not needed.

There must be a statement when you save vk11 while recording .

That has to be included.

Ok codes could be different for each tcode though.

Example

perform bdc_field       using 'BDC_OKCODE'

                              '=UPDA'.

6 REPLIES 6

Azeemquadri
Contributor
0 Kudos
209

Yes the blank values are special.

You need to refresh bdctab for every loop pass.

The first line without dynpro is not needed.

There must be a statement when you save vk11 while recording .

That has to be included.

Ok codes could be different for each tcode though.

Example

perform bdc_field       using 'BDC_OKCODE'

                              '=UPDA'.

0 Kudos
208

I do refresh the bdctab each loop pass. In the recording, I go through the transaction completing all steps, and then cilck save. When I click save it takes me to the log with the list of bdctab values. The last item on that list is the last field filled in- the Valid to date. Where would I see the step where it saved? Are there specific settings when I run the record that should be set to see this, or to actually complete the save? I think this part is what I might be missing.

0 Kudos
208

In SHDB after hitting save for VK11 go back and save the recording and then view the recording in ABAP editor.

There you will see the OK code for save.

Or you can just scroll down the recording steps and check the OKCODEs and use one which might be for VK11 save.

0 Kudos
208

BDC_OKCODE    =SICH for VK11 is the save action.

0 Kudos
208

Thanks for your help,I am getting closer. I did need to customize the lines added to the bdctab based on some variations. Now it works and saves when using CALL TRANSACTION 'VK11' USING bdctab MODE 'N', but when I use BDC_INSERT it does not save to the db tables. Is there a special commit or extra step needed to use BDC_INSERT vs CALL TRANSACTION?

0 Kudos
208

I have figured it out. The BDC_INSERT creates a session that must be manually run through SM35. I found a way to submit that automatically through the program after the group was closed and it updates the database then.

The code i used to submit the session through the program was...

DATA v_qid TYPE apq_quid.

* Post BDC session programatically


SUBMIT rsbdcsub WITH mappe = i_session       "i_session = gruop name from open_group

                     WITH von = sy-datum                    

                     WITH bis = sy-datum

                     AND RETURN.

* Displaying session for errors

* selection for qid to display session log


   SELECT SINGLE qid

   INTO v_qid

   FROM apqi

   WHERE datatyp = 'BDC'

   AND groupid = i_session

   AND progid = sy-repid

   AND userid = sy-uname

   AND credate = sy-datum.

* submit the program for BDC session error log

   IF v_qid IS NOT INITIAL.

     SUBMIT rsbdc_protocol

     WITH session = i_session

     WITH  user = sy-uname

     WITH  queue_id = v_qid

     AND RETURN.

   ENDIF.