1 1 1 1 1 Rating 0% (0 Votes)
Attachments:
Access this URL (http://abapblog.com/files/nugg/ZAB_MB51_CALL.nugg)ZAB_MB51_CALL.nugg
I've got method to get selection screen parameters to table so I can call MB51 by submitting program RM07DOCS. Of course if I do that without any changes of parameters then I would get not this list which I want (ALV kind) and MB51 would display its results on screen. That's why I need to export to memory some flags, first two must be set to be able to achieve form process_list in RM07DOCS and to get the output table for ALV, last one is my own flag which I will use in implicit enhancement to check if I should proceed with my own code and close MB51 after I'll get the results.
  • export no_list from m_flag to memory id 'MB51_NOLIST'

  • export flag from m_flag to memory id  'MB51_FLAG'.

  • export flag from m_flag to memory id 'ZMB51_FULLLIST_EXPORT'.

After submitting MB51 I'm importing results to table mt_list which is used then to move data into corresponding fields of ct_list.
  • import export to mt_list from memory id 'ZMB51_FULLLIST_EXPORT'.
Importing:

 i_selection_from_program type c default space -> if we want that method reads select options from caller
 i_progname 
type sy-repid default space -> caller name

Changing:

it_seltab type rsparams_tt optional -> selection options passed manually
ct_list type standard table -> list with results from MB51

Implementation:

method call_mb51_static.
  field-symbols<list> type any,
  <expt> type standard table,
  <expl> type any.
  datam_flag type c value 'X'.
  datamt_list type tt_list.
  datamt_exlist type ref to data.
  datams_exlist type ref to data.

  if i_selection_from_program ne space and i_progname ne space.
    call method zab_mb51_call=>get_selection_screen_criteria(
      exporting
        i_progname i_progname
      
changing
        it_seltab  it_seltab[]
                     
).
  endif.


  export no_list from m_flag to memory id 'MB51_NOLIST'.
  export flag from m_flag to memory id  'MB51_FLAG'.
  export flag from m_flag to memory id 'ZMB51_FULLLIST_EXPORT'.
  submit rm07docs with selection-table it_seltab and return .
  import export to mt_list from memory id 'ZMB51_FULLLIST_EXPORT'.
  free memory id 'ZMB51_FULLLIST_EXPORT'.

  create data mt_exlist like ct_list.
  create data ms_exlist like line of ct_list.
  assign mt_exlist->to <expt>.
  assign ms_exlist->to <expl>.

  loop at mt_list assigning <list>.
    move-corresponding <list> to <expl>.
    append <expl> to ct_list."<expt>.
    clear <expl>.
    delete table mt_list from <list>.
  endloop.

  "  ct_list[] = <expt>.
  freemt_list[]m_flag.
endmethod.