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: 

MB51 BDC Problem

Former Member
0 Kudos

I'm currently writing a BDC session that inputs some fields into the selection screen of MB51 and then executes it. Afterwards, in the BDC, it does an export to the local disk. The problem that I'm having is that sometimes when I run it I get no data, even though I know there should be. The only way to fix it is to manually run MB51 with the same parameters, and then go back and run my program. Only then will I get my data. Does anyone have an idea why this may be happening?

Thanks,

Curtis

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi ,

the MB51 transaction is a report..try to use submit report instead of BDC it will work..

report name for transaction MB51 is RM07DOCS



"see the Below example.....
  submit  RM07DOCS
          with <screen field name> in s_budat
               and return.

"or call the MB51 transactionlike this..

      set parameter id 'MAT' field liefsum-matnr.          
      set parameter id 'WRK' field liefsum-werks.         
      set parameter id 'LIF' field liefsum-lifnr.           
      set parameter id 'LAG' field g_f_lgort_initial.       
      set parameter id 'LIF' field liefsum-lifnr.           
      set parameter id 'KUN' field g_f_kunnr_initial.       
      call transaction 'MB51' and skip first screen.        

Prabhudas

9 REPLIES 9

Former Member
0 Kudos

Hi ,

the MB51 transaction is a report..try to use submit report instead of BDC it will work..

report name for transaction MB51 is RM07DOCS



"see the Below example.....
  submit  RM07DOCS
          with <screen field name> in s_budat
               and return.

"or call the MB51 transactionlike this..

      set parameter id 'MAT' field liefsum-matnr.          
      set parameter id 'WRK' field liefsum-werks.         
      set parameter id 'LIF' field liefsum-lifnr.           
      set parameter id 'LAG' field g_f_lgort_initial.       
      set parameter id 'LIF' field liefsum-lifnr.           
      set parameter id 'KUN' field g_f_kunnr_initial.       
      call transaction 'MB51' and skip first screen.        

Prabhudas

0 Kudos

Prabhudas,

Using those methods, is there a way I can automatically export the results unconverted to the local drive?

Thanks,

Curtis

0 Kudos

>

>

> Is there a way I can automatically export the results unconverted to the local drive?

>

> Thanks,

>

> Curtis

Hello Curtis,

If you are using a BDC, then do you intend to run the report in background?

If YES, you must be aware SAP GUI capabilities are unavailable in BG mode. Hence the answer will be a simple, "NO".

If NO, then no point in using BDC for this

BR,

Suhas

0 Kudos

Sorry, I forgot to finish what I wanted to say. Currently my BDC session does export the list. I was wondering if I used the methods Prabhu mentioned (the SUBMIT or CALL TRANSACTION) if there was a way to export afterwards.

To answer your question though, this program will be ran in the foreground.

Thanks,

Curtis

0 Kudos

Hello Curtis,

Can you, if possible, try to elaborate why you want to run the report in foreground & not directly access MB51?

If we know the program flow may be we can help in a better way.

BR,

Suhas

0 Kudos

Currently the people needing this run MB51 and export the data to the local disk. Then they take that data, and using another SAP screen, they create an Excel spreadsheet that they email to various people. So what I'm doing is running the report, exporting it, read the data in, find the missing information, create the Excel spreadsheets using OLE, and email the reports to whoever needs them.

0 Kudos

Maybe you can set up an implicit enhancemnt before the out put and download the file.

0 Kudos

Hi Curtis,

yes you can export the output data of MB51 into excel sheet ..



  submit <report name>
          exporting list to memory and return.   "Exporting to memory will send the output of the report to spool and memory

* read list from memory into table
  call function 'LIST_FROM_MEMORY'
    tables
      listobject = lt_listobject
    exceptions
      not_found  = 1
      others     = 2.

  if sy-subrc <> 0.
*   Error in function module &1
  endif.

*Spool content in Ascii format
  call function 'LIST_TO_ASCI'
    tables
      listobject         = lt_listobject
      listasci           = txtlines
    exceptions
      empty_list         = 1
      list_index_invalid = 2
      others             = 3.

"Now call the gui_gownload and pass txtlines internal table it will contains all the Output data of the MB51..

Prabhudas

venkatesan_nagiah
Active Participant
0 Kudos

Are you feeding all parameters in the selection screen of MB51 transaction or some of the parmeters which are set automatically ie if user name if you feed once, it will come by default. You no need to supply again. Check whether such parameter is missing in your BDC. If missing, then supply those parameters also.

Venkat