Calling the RFC Function Module via RFC Destination

 

Requirement :-

  • We have created and RFC function module in the previous part and then we created a RFC destination for the same.

Solution :-

  • Step 1 :- Go to SE38 transaction code and create a executable program.



  • Step 2 :- Create the type structure and corresponding internal table and work area for the same.



  • Step 3 :- Create a select option to take range of inputs from the user.



  • Step 3 :- Now we will the call the function module and will pass the destination name for our function module.



  • Step 4 :- Now we can display the data in form of ALV using CL_SALV_TABLE class.



Code :-

*&---------------------------------------------------------------------*
*& Report ZAR_CALLING_RFC
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT zar_calling_rfc.

TYPES : BEGIN OF ty_vbak,
          vbeln TYPE vbeln_va,
          erdat TYPE erdat,
          erzet TYPE erzet,
          ernam TYPE ernam,
          vbtyp TYPE vbtypl,
        END OF ty_vbak.

DATA : lt_vbak TYPE TABLE OF ty_vbak,
       ls_vbak TYPE ty_vbak.

DATA : lv_vbeln TYPE vbeln_va.
SELECT-OPTIONS : s_vbeln FOR lv_vbeln.

CALL FUNCTION 'ZAR_RFC_FUNCTION_MODULE' DESTINATION 'ZAR_CONNECTION'
  EXPORTING
    p_sales_document = s_vbeln[]
 IMPORTING
   LT_TABLE         = lt_vbak
  .

TRY.
CALL METHOD cl_salv_table=>factory
  EXPORTING
    list_display   = IF_SALV_C_BOOL_SAP=>FALSE
  IMPORTING
    r_salv_table   = data(lo_alv)
  CHANGING
    t_table        = lt_vbak
    .
  CATCH cx_salv_msg.
ENDTRY.
lo_alv->display( ).

Execute the Code :-



  • Press F8.


Comments

Popular posts from this blog

Understanding Different Types of SAP Function Modules: Normal, RFC, and Update

Unlocking SAP ABAP Secrets: Interactive Classical Reports with GET CURSOR, At User Command, and a Comparison of HIDE Statements

Mastering ABAP: A Step-by-Step Guide to Function Modules and Groups for Modularized Programming