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: 

Immediate Processing of BDC Session

Former Member
0 Kudos

Hi ,

In my Invoice Ouput Program ( RLB_INVOICE ), i m trying to call a transaction via BDC. The program is triggered at the point of saving VF01. But i think it does not allow us to Call a Transaction from within that program,so it throws up an 'Express Message'( ie, the program is terminated). i think Session method will work here but the problem is , i want that session to get processed immediately(in background). How can i achieve this??

ur valuable inputs awaited.

Thanks & Regards,

Bikash

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Let us take one step at a time.

You trigger the output when you are saving the invoice. In the output program you prepare the BDC data.

At this point you have a choice of doing a call transaction or creating a session. Yes, doing a call transaction in the output program will result in update termination because your output is processed in update task and any screen calls are not permitted in an update task.

Now that leaves the option of creating the session. So you create the session, and now you want that to be processed immediately. Let us say you create a session 'XYZ'. So when you do a submit RSBDCSUB passing this session name, you are getting the message 'No sessions found'.

Hope I am correct so far. Your submit of the RSBDCSUB should have picked it up. I am assuming you did BDC_OPEN_GROUP, then BDC_INSERT and then BDC_CLOSE_GROUP. If you don't do the close, then it will not work.

Can you please post the code where you are doing the RSBDCSUB? Also, for testing purpose, let us say, you will not do the submit. Can you run RSBDCSUB from another SE38 session and give this session name as input? Is it finding the session? Do you see the session in SM35 and its status is 'New'?

Srinivas

18 REPLIES 18

Former Member
0 Kudos

Hi

Check RSBDCSUB program to run sessions or job_submit function module..

sorry job_submit may not helpful in this case..

Suresh B Mannem

Message was edited by: Suresh Babu Mannem

suresh_datti
Active Contributor
0 Kudos

Hi Bikash,

You can use SUBMIT RSBDCSUB immedaitely after the session is created in your Program

Regards,

Suresh Datti

Former Member
0 Kudos

Yes. Once u complete the Session transfer and close, u can just submit program RSBDCSUB using the session parameters .

Former Member
0 Kudos

u can use this FM DB2_SCHEDULE_JOB_IMMED

Former Member
0 Kudos

Before changing to a BDC session, I think you should determine why you are getting express mail. You can use transactions SM13 and SM14 to see if there are problems with the V1 or V2 updates.

If you change to BDC, you may end up with the same problem, but who will check the session to find out?

At least with a call transaction, you can uses 'messages into itab' to see if there are any immediate problems.

Or is there a BAPI you can use instead?

Rob

0 Kudos

Thanks a lot for the replies... I used session method for my requirement noe, but still there s the problem. Rob, what is it that we need to see in SM13 to chk for its workability??

i thik Call transaction is not working as the program is an output routine and maybe it doesnnt allow to leave to other screens (not sure). Now, for session method, it says that 'No session found with status new or incorrect'.

but wen i run the program individually( as an independent report), then a session gets processed successfully..

While debugging these 2 scenarios, i found out that it selects entries from APQI table and the strange thing was that in the independent report, it was able to select a record( <b>even though the record was not there in table APQI</b>, as well as in SM35).. but this is not happening in case of my Output Program which doesnt select any record and throws the error message....

ur help needed guys.......

Thanks & Regards,

Bikash

Former Member
0 Kudos

Let us take one step at a time.

You trigger the output when you are saving the invoice. In the output program you prepare the BDC data.

At this point you have a choice of doing a call transaction or creating a session. Yes, doing a call transaction in the output program will result in update termination because your output is processed in update task and any screen calls are not permitted in an update task.

Now that leaves the option of creating the session. So you create the session, and now you want that to be processed immediately. Let us say you create a session 'XYZ'. So when you do a submit RSBDCSUB passing this session name, you are getting the message 'No sessions found'.

Hope I am correct so far. Your submit of the RSBDCSUB should have picked it up. I am assuming you did BDC_OPEN_GROUP, then BDC_INSERT and then BDC_CLOSE_GROUP. If you don't do the close, then it will not work.

Can you please post the code where you are doing the RSBDCSUB? Also, for testing purpose, let us say, you will not do the submit. Can you run RSBDCSUB from another SE38 session and give this session name as input? Is it finding the session? Do you see the session in SM35 and its status is 'New'?

Srinivas

0 Kudos

Thanks Srinivas, u ve made me feel a little comfortable now... u ve got my problem. i removed the SUBMIT in my program and found out that:

1. when i execute the report independently, a NEW session gets generated in SM35...no problem..

2. when i execute using VF01, i see that a session <b>IS</b> Generated, BUT NOT IN NEW CATEGORY, its in BEING CREATED column, and thats the reason the session doesnt process even when i run RSBDCSUB after that. dats the problem i suppose...

This is the code in the output program :

----


  • Print of a invoice by SAPscript SMART FORMS *

----


REPORT rlb_invoice.

  • declaration of data

INCLUDE rlb_invoice_data_declare.

  • definition of forms

INCLUDE rlb_invoice_form01.

INCLUDE rlb_print_forms.

*C-----BDC for reversal

INCLUDE <b>zbdcrecx2</b>. " only session method

----


  • FORM ENTRY

----


FORM entry USING return_code us_screen.

TABLES: bkpf,vbrk.

DATA: lf_retcode TYPE sy-subrc.

CLEAR retcode.

xscreen = us_screen.

PERFORM processing USING us_screen

CHANGING lf_retcode.

  • IF lf_retcode NE 0.

  • return_code = 1.

  • ELSE.

return_code = 0.

  • ENDIF.

ENDFORM. "ENTRY

----


  • FORM PROCESSING *

----


FORM processing USING proc_screen

CHANGING cf_retcode.

DATA: ls_print_data_to_read TYPE lbbil_print_data_to_read.

DATA: ls_bil_invoice TYPE lbbil_invoice.

DATA: lf_fm_name TYPE rs38l_fnam.

DATA: ls_control_param TYPE ssfctrlop.

DATA: ls_composer_param TYPE ssfcompop.

DATA: ls_recipient TYPE swotobjid.

DATA: ls_sender TYPE swotobjid.

DATA: lf_formname TYPE tdsfname.

DATA: ls_addr_key LIKE addr_key.

DATA: ls_dlv-land LIKE vbrk-land1.

DATA: ls_job_info TYPE ssfcrescl.

C**BDC for F-02 ( Reversal of line items of accounting document)

DATA : t_bseg TYPE TABLE OF bseg WITH HEADER LINE.

TYPES: BEGIN OF tp_reverse,

wrbtr_01 LIKE bseg-wrbtr,

wrbtr_40 LIKE bseg-wrbtr,

wrbtr_50 LIKE bseg-wrbtr,

bschl_01(2),

bschl_40(2),

bschl_50(2),

hkont_01(10),

hkont_40(10),

hkont_50(10),

prctr_40(10),

prctr_50(10),

END OF tp_reverse.

DATA : t_reverse TYPE tp_reverse.

DATA : g_wrbtr_01(15),

g_wrbtr_40(15),

g_wrbtr_50(15),

g_date(8),

g_vbeln(10),

g_belnr(10).

  • SmartForm from customizing table TNAPR

lf_formname = tnapr-sform.

  • determine print data

PERFORM set_print_data_to_read USING lf_formname

CHANGING ls_print_data_to_read

cf_retcode.

IF cf_retcode = 0.

  • select print data

PERFORM get_data USING ls_print_data_to_read

CHANGING ls_addr_key

ls_dlv-land

ls_bil_invoice

cf_retcode.

ENDIF.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

input = ls_bil_invoice-hd_gen-bil_number

IMPORTING

output = g_vbeln. "billing document number

C*billing document no. used to pick up the accounting doc no.

SELECT SINGLE belnr INTO g_belnr FROM bseg WHERE vbeln = g_vbeln.

SELECT * FROM bseg INTO TABLE t_bseg

WHERE belnr = '0000800643'.

CLEAR t_reverse.

LOOP AT t_bseg WHERE ( ( bschl = '01' ) OR

( bschl = '40' AND hkont = '0000542001' ) OR

( bschl = '50' AND hkont = '0000700000' ) ).

  • LOOP AT t_bseg WHERE ( ( bschl = '01' ) OR

  • ( bschl = '40' AND hkont = '0000542040' ) OR

  • ( bschl = '50' AND hkont = '0000720080' ) ).

CASE t_bseg-bschl.

WHEN '01'.

t_reverse-wrbtr_01 = t_reverse-wrbtr_01 + t_bseg-wrbtr.

t_reverse-bschl_01 = '11'.

t_reverse-hkont_01 = t_bseg-kunnr.

WHEN '40'.

t_reverse-wrbtr_40 = t_reverse-wrbtr_40 + t_bseg-wrbtr.

t_reverse-bschl_40 = '50'.

t_reverse-hkont_40 = t_bseg-hkont.

t_reverse-prctr_50 = t_bseg-prctr.

WHEN '50'.

t_reverse-wrbtr_50 = t_reverse-wrbtr_50 + t_bseg-wrbtr.

t_reverse-bschl_50 = '40'.

t_reverse-hkont_50 = t_bseg-hkont.

t_reverse-prctr_40 = t_bseg-prctr.

ENDCASE.

ENDLOOP.

g_wrbtr_01 = t_reverse-wrbtr_01.

g_wrbtr_40 = t_reverse-wrbtr_40.

g_wrbtr_50 = t_reverse-wrbtr_50.

g_date(2) = sy-datum+6(2).

g_date2(2) = sy-datum4(2).

g_date+4(4) = sy-datum(4).

CONDENSE: g_wrbtr_01,g_wrbtr_40,g_wrbtr_50.

PERFORM open_group.

PERFORM bdc_dynpro USING 'SAPMF05A' '0100'.

PERFORM bdc_field USING 'BDC_CURSOR'

'RF05A-NEWKO'.

PERFORM bdc_field USING 'BDC_OKCODE'

'/00'.

PERFORM bdc_field USING 'BKPF-BLDAT'

g_date.

PERFORM bdc_field USING 'BKPF-BUKRS'

'1000'.

PERFORM bdc_field USING 'BKPF-BUDAT'

g_date.

PERFORM bdc_field USING 'BKPF-WAERS'

'INR'.

PERFORM bdc_field USING 'BKPF-BKTXT'

'AMC REVERSAL'.

PERFORM bdc_field USING 'RF05A-NEWBS'

t_reverse-bschl_01.

PERFORM bdc_field USING 'RF05A-NEWKO'

t_reverse-hkont_01.

PERFORM bdc_dynpro USING 'SAPMF05A' '0301'.

PERFORM bdc_field USING 'BDC_CURSOR'

'BSEG-SGTXT'.

PERFORM bdc_field USING 'BDC_OKCODE'

'/00'.

PERFORM bdc_field USING 'BSEG-WRBTR'

g_wrbtr_01.

PERFORM bdc_field USING 'RF05A-NEWBS'

t_reverse-bschl_40.

PERFORM bdc_field USING 'RF05A-NEWKO'

t_reverse-hkont_40.

PERFORM bdc_dynpro USING 'SAPMF05A' '0300'.

PERFORM bdc_field USING 'BDC_CURSOR'

'BSEG-SGTXT'.

PERFORM bdc_field USING 'BDC_OKCODE'

'/00'.

PERFORM bdc_field USING 'BSEG-WRBTR'

g_wrbtr_40.

PERFORM bdc_field USING 'RF05A-NEWBS'

t_reverse-bschl_50.

PERFORM bdc_field USING 'RF05A-NEWKO'

t_reverse-hkont_50.

PERFORM bdc_dynpro USING 'SAPLKACB' '0002'.

PERFORM bdc_field USING 'BDC_CURSOR'

'COBL-PRCTR'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=ENTE'.

PERFORM bdc_field USING 'COBL-PRCTR'

t_reverse-prctr_40.

PERFORM bdc_field USING 'BDC_OKCODE'

'=ENTE'.

PERFORM bdc_dynpro USING 'SAPMF05A' '0300'.

PERFORM bdc_field USING 'BDC_CURSOR'

'RF05A-NEWKO'.

PERFORM bdc_field USING 'BSEG-WRBTR'

g_wrbtr_50.

PERFORM bdc_dynpro USING 'SAPLKACB' '0002'.

PERFORM bdc_field USING 'BDC_CURSOR'

'COBL-PRCTR'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=ENTE'.

PERFORM bdc_field USING 'COBL-PRCTR'

t_reverse-prctr_50.

PERFORM bdc_field USING 'BDC_OKCODE'

'=ENTE'.

PERFORM bdc_dynpro USING 'SAPMF05A' '0300'.

PERFORM bdc_field USING 'BDC_CURSOR'

'RF05A-NEWKO'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=BU'.

PERFORM bdc_dynpro USING 'SAPLKACB' '0002'.

PERFORM bdc_field USING 'BDC_CURSOR'

'COBL-PRCTR'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=ENTE'.

PERFORM bdc_field USING 'COBL-PRCTR'

t_reverse-prctr_50.

PERFORM bdc_transaction USING 'F-02'.

C*running the Session Immediately using variant AMC

  • SUBMIT rsbdcsub USING SELECTION-SET 'AMC'.

ENDFORM. "PROCESSING

MY INCLUDE :

***INCLUDE ZBDCRECX2.

  • for programs doing a data transfer by creating a batch-input session

  • and

  • for programs doing a data transfer by CALL TRANSACTION USING

----


  • data definition

----


  • Batchinputdata of single transaction

DATA: BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.

  • messages of call transaction

DATA: MESSTAB LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.

  • error session opened (' ' or 'X')

DATA: E_GROUP_OPENED.

  • message texts

TABLES: T100.

----


  • open dataset *

----


FORM OPEN_DATASET USING P_DATASET.

OPEN DATASET P_DATASET

FOR INPUT IN TEXT MODE

ENCODING DEFAULT.

IF SY-SUBRC <> 0.

WRITE: / TEXT-E00, SY-SUBRC.

STOP.

ENDIF.

ENDFORM.

----


  • close dataset *

----


FORM CLOSE_DATASET USING P_DATASET.

CLOSE DATASET P_DATASET.

ENDFORM.

----


  • create batchinput session *

  • (not for call transaction using...) *

----


FORM OPEN_GROUP.

CALL FUNCTION 'BDC_OPEN_GROUP'

EXPORTING CLIENT = SY-MANDT

GROUP = 'AMC_REVERSAL'

USER = sy-uname.

ENDFORM.

----


  • end batchinput session *

  • (call transaction using...: error session) *

----


FORM CLOSE_GROUP.

CALL FUNCTION 'BDC_CLOSE_GROUP'.

ENDFORM.

----


  • Start new transaction according to parameters *

----


FORM BDC_TRANSACTION USING TCODE.

DATA: L_MSTRING(480).

DATA: L_SUBRC LIKE SY-SUBRC.

CALL FUNCTION 'BDC_INSERT'

EXPORTING TCODE = TCODE

TABLES DYNPROTAB = BDCDATA.

REFRESH BDCDATA.

ENDFORM.

----


  • Start new screen *

----


FORM BDC_DYNPRO USING PROGRAM DYNPRO.

CLEAR BDCDATA.

BDCDATA-PROGRAM = PROGRAM.

BDCDATA-DYNPRO = DYNPRO.

BDCDATA-DYNBEGIN = 'X'.

APPEND BDCDATA.

ENDFORM.

----


  • Insert field *

----


FORM BDC_FIELD USING FNAM FVAL.

IF FVAL <> '/'.

CLEAR BDCDATA.

BDCDATA-FNAM = FNAM.

BDCDATA-FVAL = FVAL.

APPEND BDCDATA.

ENDIF.

ENDFORM.

0 Kudos

Unless I missed the obvious, I didn't find BDC_CLOSE_GROUP being called in your output program. Here is the extract of your code.


PERFORM bdc_transaction USING 'F-02'.

*C**running the Session Immediately using variant AMC
* SUBMIT rsbdcsub USING SELECTION-SET 'AMC'.

As you can see, you don't have the BDC_CLOSE_GROUP call between your bdc_transaction call and the SUBMIT.

Change it as follows.


PERFORM bdc_transaction USING 'F-02'.
PERFORM close_group.
SUBMIT rsbdcsub USING SELECTION-SET 'AMC'.

Hope this resolves your problem.

Srinivas

0 Kudos

Thanks for the reply, Srinivas, i had found that out n also inserted it, but still a problem persists... Now, the session is getting generated as NEW, but the SUBMIT is terminating the update again. i removed the submit & its working fine with the session getting generated as NEW & i can process it using RSBDCSUB after that.. But again my purpose of 'NO MANUAL INTERVENTION' is not getting solved here... have raised a message to SAP but since its a weekend havent received any reply...& i need to complete this report apart from others by Tuesday(Go-LIVE date)... do u have any idea abt this dude????

Thanks & Regards,

Bikash

0 Kudos

Hi Bikash,

for whtever it is worth try this..

SUBMIT rsbdcsub USING SELECTION-SET 'AMC' and return.

Regards,

Suresh Datti

0 Kudos

I think the SUBMIT is the one causing it. You have two options now. As I mentioned earlier, instead of doing the SUBMIT, raise an event(SM62 and SM64) and schedule the RSBDCSUB as a job to be started after the event. So the flow will be, output is triggered, you create the session, and you then raise the event(BP_EVENT_RAISE) and the event then starts the job that is defined to run when the event is raised. The job will execute the RSBDCSUB.

The second option is to create the job in this program itself and insert RSBDCSUB as a step in this job. Here is the code for that.


*-- run in the background
      CALL FUNCTION 'JOB_OPEN'
           EXPORTING
                jobname          = 'REVERSE_ENTRIES'
           IMPORTING
                jobcount         = v_jobcount
           EXCEPTIONS
                cant_create_job  = 1
                invalid_job_data = 2
                jobname_missing  = 3
                OTHERS           = 4.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE 'E' NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        EXIT.
      ENDIF.
      SUBMIT rsbdcsub WITH mappe = 'MYSESSION'
                      USER sy-uname 
                   VIA JOB 'REVERSE_ENTRIES' 
                    NUMBER v_jobcount AND RETURN.
      CALL FUNCTION 'JOB_CLOSE'
           EXPORTING
                jobcount             = v_jobcount
                jobname              = 'REVERSE_ENTRIES'
                strtimmed            = 'X'
           EXCEPTIONS
                cant_start_immediate = 1
                invalid_startdate    = 2
                jobname_missing      = 3
                job_close_failed     = 4
                job_nosteps          = 5
                job_notex            = 6
                lock_failed          = 7
                OTHERS               = 8.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE 'W' NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.

0 Kudos

u r right Srinivas, the SUBMIT command is the problem. So, in that case ur 2nd option also wont work as it also involves SUBMIT... EVENT triggering seems to be a good idea. Cud u please explain me the steps to go abt the same. I called FM BP_EVENT_RAISE and passed the event name that i created in SM62. After that i tried scheduling the job to trigger the program 'after that event' in SM36 but cudnt as i m doin it the first time. Cud u please explain me the overall process from SM62 to job scheduling??

Suresh, i tried everything with SUBMIT, it doesnt work

Thanks & Regards,

Bikash

0 Kudos

Hi Bikash,

another option could be..

put your SUBMIT RSBDCSUB code inside a custom function module..

and call that function using the STARTING NEW TASK option.. this way the SUBMIT would have its own LUW & will not interrupt the original update process.. you can pass the session name via the function call..just throwing a suggestion.. just in case...

Regards,

Suresh Datti

0 Kudos

Even though you are using SUBMIT in the second option, you are putting that into a job as a step. So it will not have the same effect as if you had a normal submit. So try it and see if it works.

For the events, it looks like you followed all the required steps for the events. Did you activate the event using SM64?

0 Kudos

Suresh, ur FM was an interesting proposition ans i tried that. i did something like this.

<b>call function 'ZAMC' starting new task 'AMC1'.</b>

(i didnt exactly understand this new task concept though).

and in the FM , i have

FUNCTION ZAMC.

*"----


""Local Interface:

*"----


submit rsbdcsub using selection-set 'AMC'.

ENDFUNCTION.

also, i have the processing type as <b>'remote-enabled'</b>(not sure if this is necessary). New session is getting generated here, but its not getting processed. Now, if i take an old billing document, and save the same from VF02, then it works fine, dont understand why this happens. Also, the sad part is i m not able to see the problem as it doesnt stop in my program in debugging mode..

Srinivas, the SUBMIT doesnt work even in this case, same Update Termination Express Message..

Also, please let me know the steps for triggering the event n scheduling..were u talkin abt triggering the event from SM64?? there is no key as activate event there..r u in some messenger so that i can contact u more easily???

Thanks & regards,

Bikash

0 Kudos

Hi Bikash,

The fact that it didn't terminate the update is encouraging enough... actually the STARTING NEW TASK is used for calls to external systems.. In your case, you need not RFC enable it.. You can try by changing the function call to

CALL FUNCTION func IN BACKGROUND TASK as SEPARATE UNIT. This executes the function module in a separate LUW under a new transaction ID. That is the reason you are unable to debug it.. You have to use SMO4, identify your process & enter into debug mode via the backdoor...

Regards,

Suresh Datti

0 Kudos

Thanks to Srinivas & Suresh for ur great support. i ve used CALL FUNCTION func IN BACKGROUND TASK as SEPARATE UNIT n it seems to work now. There was still some problem in the Event Triggering option though Srinivas, but thanks a lot for ur help.... I hope i wont get any other issue in this object...

Thanks a ton..!!