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

Problem in bapi_transaction_commit

Former Member
0 Likes
1,251

Dear Friends,

I have done one alv report with checkboxes which displays blocked billing plan line items.

I put a execute button, for selected records it is to be processed and the status get unblocked in dbase.

i have done this using some fm's start with SD_SALES....

at last i am calling bapi_transaction_commit it is working fine..

After that i am using bdc for vf01 and it's working fine and i got the messages into one itab.

But how do i display that data in the screen ?

I have to display the data in the same screen by refresh it.

How do i achieve this...?

My requirement is after click on execute it has display the Billing Numbers which are genarated..


when 'EXECUTE'.
---
----
---
        refresh it_bdcdata.
* BDC for Invoice Creation
        v_index = v_index + 1. "SY-TABIX.
        perform bdc_dynpro      using 'SAPMV60A' '0102'.
        perform bdc_field       using 'BDC_CURSOR'
                                      'KOMFK-VBELN( V_INDEX )'. "'KOMFK-VBELN(01)'.
        perform bdc_field       using 'BDC_OKCODE'
                                '/00'.
        concatenate 'KOMFK-VBELN(' v_index ')' into v_fnam.
        perform bdc_field       using v_fnam
                                wa_process-vbeln. "'40000003'.
        clear v_fnam.
       perform bdc_dynpro      using 'SAPMV60A' '0104'.
        perform bdc_field       using 'BDC_OKCODE'
                                '=SICH'.
        call transaction 'VF01' using it_bdcdata mode   'A'
                                                 update 'S'
                                                 messages into it_msg.
        perform bdc_messages.
      endloop.

      loop at it_error into wa_error.  " Here i am getting those billing numbers
        write : / wa_error-msg_err.
        clear wa_error.
      endloop.

13 REPLIES 13
Read only

Former Member
0 Likes
1,224

Hi Friend,

Can you please explain your requirement more clearly.

Regards,

Praveenkumar T.

Read only

0 Likes
1,224

Dear Praveen,

I am displaying an alv report with check boxes.

for selecteding records i am unblocking some records(Using fm's- commit work)

for those creating invoice(vf01-BDC).

ALL is well .. i am getting messages into one internal table.

now i want to display that messages in that screen(means after execute).

Read only

0 Likes
1,224

Hi,

After BDC Process completion r using FORMAT_MESSAGE..

From IT_MSG you can display.

Regards,

Praveen.

Read only

0 Likes
1,224

HI Friend,

If i have understood your requirement correctly , you have created invoice for the unblocked records and you have to display all the invoice document number created in a screen after clicking on execute.

This can be achieved. Please follow the below process,

As soon as the BDC is over , you can write a SELECT query in VBRK table to fetch the records based on the condition ERDAT EQ sy-datum AND ENNAM EQ sy-uname.

Now you will have all the records created.

If you are going to run the program more than once in a day, then add one more condition ERZET GE lv_uzeit.

This lv_uzeit has to be set at the initialization as given below,

DATA: lv_uzeit TYPE sy-uzeit.

INITIALIZATION.
lv_uzeit = sy-uzeit.

<UNBLOCK>
<BDC>

SELECT VBELN FROM VBRK INTO IT_VBELN
WHERE ERNAM EQ sy-uname
    AND  ERZET  GE lv_uzeit
    AND  ERDAT  EQ sy-datum.

Now the table it_vbeln will have all the billing documents created during the execution.

LOOP AT it_vbeln INTO WA_VBELN

WRITE : wa_vbeln-vbeln.

ENDLOOP.

Thus after clicking on execute you will have all the created invoice documents displayed.

"NOTE: Your it_msg table will have all the numbers but it will also have other message as well hence it is better to go with the above approach."

Hope this helps.

Regards,

Praveenkumar T.

Read only

0 Likes
1,224

Dear All,

I have done the things what you said.

but my requriement is i want to display the invoice numbers(message created) in separate screen.

Here i am getting the message in status bar of lastly created invoice number.

the loop is not displaying in another screen.

Kindly note that it is an interactive report.

Edited by: anurag.radha on Feb 22, 2012 2:23 PM

Read only

0 Likes
1,224

Hi,

Did you write same select query I have mentioned. and use the write statement as shown in the code?

After select you should write this code as well.

LOOP AT it_vbeln INTO WA_VBELN
WRITE : /n wa_vbeln-vbeln.
ENDLOOP.

if that is done i am very sure that it will display the list of invoice number in a different screen.

Regards,

Praveenkumar T.

Read only

Harsh_Bansal
Contributor
0 Likes
1,224

Hi,

You can simply Loop at it_msg and write the lines.

It will display your messages.

And if you want to display only successful cases then you can -

LOOP AT it_msg INTO wa_msg WHERE msgtyp = 'S'.

ENDLOOP.

Regards,

Harsh Bansal

Read only

Former Member
0 Likes
1,224

Hi Anurag,

Please use:


DATA:  it_msg LIKE bdcmsgcoll OCCURS 0 WITH HEADER LINE.
DATA : v_msg(255) TYPE c.

LOOP AT IT_MSG WHERE msgtyp = 'S'.

CALL FUNCTION 'FORMAT_MESSAGE'
        EXPORTING
          id        = it_msg-msgid
          lang    = 'E'
          no      = it_msg-msgnr
          v1      = it_msg-msgv1
          v2      = it_msg-msgv2
          v3      = it_msg-msgv3
          v4      = it_msg-msgv4
        IMPORTING
          msg       = v_msg
        EXCEPTIONS
          not_found = 1
          OTHERS    = 2.

ENDLOOP.

Edited by: Ajoy Chakraborty on Feb 22, 2012 5:54 PM

Read only

Harsh_Bansal
Contributor
0 Likes
1,224

Hi,

Just use Write statement in Loop to display messages.

Then it will come in a new screen.

Regards,

Harsh Bansal

Read only

0 Likes
1,224

Dear harsh Bansal,

I tried this but it is not displaying in the new screen.


        call transaction 'VF01' using it_bdcdata mode  'N'
                                                 update 'S'
                                                 messages into it_msg.

        select single vbeln from vbrk into wa_vbrk
        where ernam eq sy-uname
            and  erzet  ge lv_uzeit
            and  erdat  eq sy-datum
            and  ernam  eq sy-uname.
        append wa_vbrk to it_vbrk.
        clear wa_vbrk.
      endloop.
      loop at it_vbrk into wa_vbrk.
        write : / wa_vbrk-vbeln color 5.
        clear wa_vbrk.
      endloop.

Read only

0 Likes
1,224

Hi,

Write your SELECT query outside the BDC LOOP. If it is inside the loop it will always fetch the same data. since you have used select single.

Also check if the Internal table it_vbrk is not Empty.

you code should look like.

call transaction 'VF01' using it_bdcdata mode  'N'
                                                 update 'S'
                                                 messages into it_msg.
  
      endloop.

    select  vbeln from vbrk into table it_vbrk
        where ernam eq sy-uname
            and  erzet  ge lv_uzeit
            and  erdat  eq sy-datum.

IF it_vbrk IS NOT INITIAL.
             loop at it_vbrk into wa_vbrk.
        write : / wa_vbrk-vbeln color 5.
        clear wa_vbrk.
      endloop..
ENDIF.

Please revert if you still face problems.

Regards,

Praveenkumar T.

Read only

0 Likes
1,224

Dear Praveen,

Still it is not working.

i debugged it it goes to that loop and displaying.

Any way i resolved this by passing this it_vbrk to reuse_alv-grid_display.

it works fine.

Thnak you so much all.

Read only

Harsh_Bansal
Contributor
0 Likes
1,224

This should work actually.

Did you try debugging it from Select statement onwards??

Regards,

Harsh Bansal