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: 

Process 2 BDCs in 1 program problem

Former Member
0 Kudos

Hi,

I created a program that submits the BDC session 2 times to process the creation and the change of a transaction code. I can't seem to make it to work in terms of processing the first BDC and then the second BDC automatically. There is a timing issue. Has anyone done this without problems.

Thanks

Will

1 ACCEPTED SOLUTION

Former Member
0 Kudos

try to have to use of BAPIs in place of BDC.

1.Bcos , in the program itself u wll come to know what u created, but in BDC u dont have any data to process second BDC for change.

2.U can skip Error transactions in program itself.

Regards

prabhu

18 REPLIES 18

Former Member
0 Kudos

try to have to use of BAPIs in place of BDC.

1.Bcos , in the program itself u wll come to know what u created, but in BDC u dont have any data to process second BDC for change.

2.U can skip Error transactions in program itself.

Regards

prabhu

0 Kudos

Hi,

I am able to create BDCs that would process with no error automatically. Would you happen to know if there are BAPIs for GS01 and GS04? I created BDcs for these and am procesiing in 1 program. Another solution is to separate the program into 2 for GS01 and GS04, but I would prefer to have just 1 program.

Thanks

0 Kudos

HI Will

Please try by delaying the processing of second session by WAIT statement.

Something like <b>COMMIT WORK AND WAIT</b>.

Kind Regards

Eswar

0 Kudos

check

G_SET_CREATION or G_SET* in SE37.

<b>i dont think we can make use of Commands like COMMIT Work and WAIT in any BDC's.bcos SAP itself commit the work when u sumbit Session or call trasaction.But in case of BAPI then we can use COMMIT work Command.

may be i am wrong?

<b>yeah , in case of GS* i think there is no such BAPIs.Thats y i have given FMs which is used in the program of GS01 itself while creating the SETS.

1.If u ask me i will do it in one program itself ? But problem is that SOme time SAP will take time to Update tables.If Ur data is independent of transactions then u can go with one program itself , other wise u have to maintain 2 objects to do so.

2.Actually what u are doing ?

as per my understandings--->first u will create a new SETS then u will going to delete old ones with tcode GS04 ?</b>

Regards

Prabhu

Message was edited by:

Prabhu Peram

0 Kudos

Hi,

How often and where I should use the COMMIT AND WAIT or WAIT statements. I am using the statement SUBMIT RSBDCSUB. I also have a native SQL statement to refresh my Z table. I am getting a runtime error for updating the table with duplicate records but really there is no record in the table. It has to do with some timing issue that is causing the program not to recognized that the tasble is empty and can be updated with records.

Thanks

0 Kudos

Hi Prabhu ,

Since I have the BDC program to work, it seems that either I would have to separate the BDC for GS01 and GS04 into 2 programs, which then it would be not that efficient, so that's why I am trying to make it work in 1 program. I look at the BAPIs for the sets before, and it seems that I was not able to find the ones for my requirement.

Any other ideas or would you suggest to create 2 programs for the sake of getting this resolved?

Thanks

0 Kudos

Hi,

Duplicate error some times occurs if you already have a record with no entry(no value for field) and trying to insert a blank record again.Because in that case,key field values will be blank twice.So check whether the database table is having a blank record and your program is trying to insert blank record.

0 Kudos

Hi,

I have to keep track of the sets in a table and then use that to delete the sets by reading the Z table.

Thanks

0 Kudos

Hi Will,

The process is

loop .

Create  BDC " for creation '
commit work.

Change BDC  " for Change .
commit work.

endloop.

For when the BDC is submitted to the Ok code screen ?(Confirming the record is created )then you need to use Commit Work in order to update the tables

Here the point to observe is <b>what if the commit work is not done forcibly</b>.

1. The loop <b>processing time</b> is much faster than the screen submission(bdc) in the create mode /change mode.

2.

If this time elapses before getting the record created and the loop has already started the change record for that entry(iteration2) (Note here there is clear Possibilty of running into a change record even before the record was updated giving prone to duplicate / major error as the record was not identified.

3.Once the duplicate error ''

here this is possible

(jayanthi's remark )

Duplicate error some times occurs if you already have a record with no entry(no value for field) and trying to insert a blank record again.

A blank record is inserted into table although clearly there is no entry but repeating it one more time will trigger the error has duplicate.

so u need to take care of this .

4. In my opinion u need to force the commit work (Eswars remark) to update the table once the session for creation / change is done .

You need to do this at both the ends(create as well as change ).

I think u can see after making the necessary changes by bringing in the commit of that transaction and see this.

For reference you see this STD Fm IDOC_INPUT_ORDERS and make a search on COMMIT Work .

The same logic holds true for idocs i will be sending 100 records in a span of time interval i cannot wait till the system has processed it.

But by opting call transaction and updating in async mode i can achieve this .

 IF      Ok_code  (or) Save  .
          COMMIT WORK.  " force to commit.
 ENDIF.

hope this helps ,

regards,

Vijay

0 Kudos

Hi Vijay,

Thanks for the detailed explanation. I ended up separating the program in 2 and it worked GREAT. The table was updating and the BDCs were automtically processed. I will try to put the COMMIT WORK after these statements

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'=SAVE'.

COMMIT WORK

just to see if I could combine 2 BDC processinbg into 1. It is always preferred to have just 1 program to do everything. It seems that the prefer approach would be to separate it into 2 programs.

Thanks gain for taking the time to explain the timing issue about the loop. When I was doing this I didn't think about it.

0 Kudos

When using CALL TRANSACTION and BDC, there is no need to do a COMMIT WORK anywhere, because the COMMIT WORK is automatically applied when the CALL TRANSACTION ends. There is no problem with calling 2 different BDC(Call transactions) in the same program as I've done many time before with no problems.

I see here you are using sessions, I would assume that the same applies about the COMMIT WORK within a session, it does a CALL TRANSACTION internally anyway, and does the COMMIT WORK automatically.

Regards,

RIch Heilman

0 Kudos

Hi Rich,

What's a boy to do, so many suggestions and not enough time to test them out...

So how did you do this?

This is my process when working with 1 program. I have the following sequence of processing.

1. Check the table Z to see if there are sets created have been created before

2. If there are sets then delete the sets using the BDC

3. Submit BDC

4. Refresh the Z table uisng SQL Native TRUNCATE

5. Create sets

6. Update Z table with sets just created

7. Submit BDC

I am using the following

SUBMIT RSBDCSUB

WITH MAPPE EQ GROUP

WITH VON EQ SY-DATUM

WITH BIS EQ SY-DATUM

WITH FEHLER EQ SPACE

EXPORTING LIST TO MEMORY

AND RETURN.

and I am using the INCLUDE BDCRECX1 that was created when I did the recording.

The things I did was simple nothing was out of the ordinary to cause the BDCS to stop at SM35 and then I would have to manually submit the session to work.

Thanks

Will

0 Kudos

Do you have to run them as sessions? If not, just call the transactions directly from the program using CALL TRANSACTION using BDCDATA, you can get rid of that INCLUDE if you don't want the selection screen that comes with it. All you need is the DATA statement for the BDCDATA and the FORMs which you use to fill the BDC data table. Can you post your code?

Regards,

Rich Heilman

0 Kudos

Hi Rich,

Well ... you know the normal procedure to process the transction and here is the code that I use for posting the transaction.

PERFORM BDC_TRANSACTION USING 'GS01'.

PERFORM CLOSE_GROUP.

SUBMIT RSBDCSUB

WITH MAPPE EQ GROUP

WITH VON EQ SY-DATUM

WITH BIS EQ SY-DATUM

WITH FEHLER EQ SPACE

EXPORTING LIST TO MEMORY

AND RETURN.

COMMIT WORK AND WAIT.

Here is the code for BDC_TRANSACTION from the INCLUDE:

FORM BDC_TRANSACTION USING TCODE.

DATA: L_MSTRING(480).

DATA: L_SUBRC LIKE SY-SUBRC.

  • batch input session

IF SESSION = 'X'.

CALL FUNCTION 'BDC_INSERT'

EXPORTING TCODE = TCODE

TABLES DYNPROTAB = BDCDATA.

IF SMALLLOG <> 'X'.

WRITE: / 'BDC_INSERT'(I03),

TCODE,

'returncode:'(I05),

SY-SUBRC,

'RECORD:',

SY-INDEX.

ENDIF.

  • call transaction using

ELSE.

REFRESH MESSTAB.

CALL TRANSACTION TCODE USING BDCDATA

MODE CTUMODE

UPDATE CUPDATE

MESSAGES INTO MESSTAB.

L_SUBRC = SY-SUBRC.

IF SMALLLOG <> 'X'.

WRITE: / 'CALL_TRANSACTION',

TCODE,

'returncode:'(I05),

L_SUBRC,

'RECORD:',

SY-INDEX.

LOOP AT MESSTAB.

SELECT SINGLE * FROM T100 WHERE SPRSL = MESSTAB-MSGSPRA

AND ARBGB = MESSTAB-MSGID

AND MSGNR = MESSTAB-MSGNR.

IF SY-SUBRC = 0.

L_MSTRING = T100-TEXT.

IF L_MSTRING CS '&1'.

REPLACE '&1' WITH MESSTAB-MSGV1 INTO L_MSTRING.

REPLACE '&2' WITH MESSTAB-MSGV2 INTO L_MSTRING.

REPLACE '&3' WITH MESSTAB-MSGV3 INTO L_MSTRING.

REPLACE '&4' WITH MESSTAB-MSGV4 INTO L_MSTRING.

ELSE.

REPLACE '&' WITH MESSTAB-MSGV1 INTO L_MSTRING.

REPLACE '&' WITH MESSTAB-MSGV2 INTO L_MSTRING.

REPLACE '&' WITH MESSTAB-MSGV3 INTO L_MSTRING.

REPLACE '&' WITH MESSTAB-MSGV4 INTO L_MSTRING.

ENDIF.

CONDENSE L_MSTRING.

WRITE: / MESSTAB-MSGTYP, L_MSTRING(250).

ELSE.

WRITE: / MESSTAB.

ENDIF.

ENDLOOP.

SKIP.

ENDIF.

    • Erzeugen fehlermappe ************************************************

IF L_SUBRC <> 0 AND E_GROUP <> SPACE.

IF E_GROUP_OPENED = ' '.

CALL FUNCTION 'BDC_OPEN_GROUP'

EXPORTING CLIENT = SY-MANDT

GROUP = E_GROUP

USER = E_USER

KEEP = E_KEEP

HOLDDATE = E_HDATE.

E_GROUP_OPENED = 'X'.

ENDIF.

CALL FUNCTION 'BDC_INSERT'

EXPORTING TCODE = TCODE

TABLES DYNPROTAB = BDCDATA.

ENDIF.

ENDIF.

REFRESH BDCDATA.

ENDFORM.

According to this INCLUDE, it is using the CALL TRANSACTION per your suggestion.

OK... I will not keep the standard INCLUDE to make my program to work. Iw ill have to write my own BDCDATA. I was thinking I could get this to work in no time but no time is taking me a month to do this... or at least some hot head complained that I am taking this a month to do it.

Ha Ha Ha...

Thanks and regards

Will

0 Kudos

Please post all of the code of the program or send to my email on my business card, I can then modify and send back to you for testing.

Regards,

Rich Heilman

0 Kudos

HI Will

I guess i got your problem. Will try to explain as per my understanding:

When we SUBMIT program RSBDCSUB within a program, the control leaves the program and executes RDBDCSUB as a separate process.

As per your process, the processing of second session might have started before all V1 updates have been completed and hence resulting in error SET NOT FOUND.

Maybe you can handle the case by creating a JOB and SUBMITTING RSBDCSUB twice as steps for the job, so they can execute one after the other.

For creating job, we can make use of FM's: <b>JOB_OPEN, JOB_SUBMIT & JOB_CLOSE</b>. Functionality of JOB_SUBMIT can also be acheived by SUBMIT via JOBCOUNT....

My concern here is updating the Z table with the sets created. I guess for this you have to created a small program which can update the ZTABLE and include SUBMITTING this program as a second step in the job.

Hope this way you can handle the situation.

Rich and other friends, i request you to correct me if my understanding is wrong.

Kind Regards

Eswar

0 Kudos

Hi Eswar,

An update on this. Thanks so much for doing the analysis and recommendations. I was able to solve the problem by correcting my probgram according to Rich's suggestions:

1. Exclude the use of the INCLUDE BDCRECX1.

2. I no longer use statements PERFORM OPEN_GROUP, PERFORM CLOSE_GROUP, SUBMIT RSBDCSUB using the code from the INCLUDE BDCRECX1

3. I am now using the following PERFORMs:

FORM BDC_DYNPRO USING PROGRAM DYNPRO.

CLEAR BDCDATA.

BDCDATA-PROGRAM = PROGRAM.

BDCDATA-DYNPRO = DYNPRO.

BDCDATA-DYNBEGIN = 'X'.

APPEND BDCDATA.

ENDFORM. " BDC_DYNPRO

FORM BDC_FIELD USING FNAM FVAL.

CLEAR BDCDATA.

BDCDATA-FNAM = FNAM.

BDCDATA-FVAL = FVAL.

APPEND BDCDATA.

ENDFORM. " BDC_FIELD

4. I now also use the statements:

CLEAR BDCDATA.

REFRESH BDCDATA.

5. I am calling the transaciton directly and not going through the BDC sessions

CALL TRANSACTION 'GS01' USING BDCDATA

MODE 'N'

UPDATE 'L'.

6. I now have 1 program to do 2 updates to transactions GS01 and GS04.

7. The update to my Z table works

8. The only thing I would recommend is to use the BDC session method initially to create and test your program until it works. The BDC helps in doing error analysis for the screen updates.

9. Once you have the program working then you can exlcude using the BDC session method.

Thanks and regards

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

Did you tried using WAIT UP TO n SECONDS ?