SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Submitting an ALV program and get output



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ALV Grid / ALV Tree / ALV List
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1640

PostPosted: Mon Aug 06, 2012 4:27 pm    Post subject: Submitting an ALV program and get output Reply with quote

Code:
TYPE-POOLS: imrep, slis.
INCLUDE rm07mldd.

DATA:  ls_data TYPE REF TO data.

FIELD-SYMBOLS: <lt_data> TYPE table,
               <l_data> TYPE data.

SELECT-OPTIONS: so_budat FOR mkpf-budat.

START-OF-SELECTION.

  cl_salv_bs_runtime_info=>set(
        display  = abap_false
        metadata = abap_false
        data     = abap_true ).

  SUBMIT rm07mlbd WITH datum IN so_budat
            AND RETURN.

  TRY.
      cl_salv_bs_runtime_info=>get_data_ref(
      IMPORTING r_data = ls_data ).
      ASSIGN ls_data->* TO <lt_data>.
    CATCH cx_salv_bs_sc_runtime_info.
      MESSAGE `Unable to retrieve ALV data` TYPE 'E'.
  ENDTRY.

END-OF-SELECTION.

  cl_salv_bs_runtime_info=>clear_all( ).

  LOOP AT <lt_data> ASSIGNING <l_data>.
    MOVE-CORRESPONDING <l_data> TO g_t_belege1.
    WRITE: / g_t_belege1-mblnr,
             g_t_belege1-mjahr,
             g_t_belege1-budat.
  ENDLOOP.




Comment by Sougata Chatterjee:
It is possible to get back the metadata (and the data) into the calling program by setting a parameter = 'X' in the SET( ) method as per the code below but it is not possible to return an instance of the ALV Grid object of the called program - please note the difference.

Also, this method does not return the details of the layout variant. As a result it is not possible to construct an internal table dynamically with the same structure as the layout variant itself (that was chosen in the called program RFITEMAP) via the call of the GET_METADATA( ) method. The fieldcatalog does not return specific info in regards to the layout variant but it returns all the fields of the grid into the fieldcatalog after the GET_METADATA( ) method is called.
Code:

DATA:
  lr_pay_conf_data TYPE REF TO data,
  ls_metadata TYPE cl_salv_bs_runtime_info=>s_type_metadata.

FIELD-SYMBOLS:
  <lt_pay_conf_data> TYPE STANDARD TABLE,
  <ls_pay_conf_data> TYPE ANY,
  <lv_field>         TYPE ANY.

START-OF-SELECTION.

  cl_salv_bs_runtime_info=>set(
      EXPORTING display  = abap_false
               metadata = abap_true
                data     = abap_true ).

  SUBMIT rfitemap USING SELECTION-SET 'VAR_RFITEMAP' AND RETURN.

  cl_salv_bs_runtime_info=>get_data_ref(
       IMPORTING r_data = lr_pay_conf_data ).
  ASSIGN lr_pay_conf_data->* TO <lt_pay_conf_data>.

END-OF-SELECTION.
  TRY.
      ls_metadata = cl_salv_bs_runtime_info=>get_metadata( ).
    CATCH cx_salv_bs_sc_runtime_info .
  ENDTRY.

As I pointed out in my last post, the approach here is incorrect and this technique should not be used to meet this requirement at hand. It is a much better approach to copy the standard program into a custom program then apply changes to the business logic as required.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ALV Grid / ALV Tree / ALV List All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.