Showing posts with label RFC FM. Show all posts
Showing posts with label RFC FM. Show all posts

Thursday, October 1, 2020

Remote Function Call (RFC) & types of RFC’s in SAP ABAP.

 What is Remote Function Call (RFC) & types of RFC’s?



Ans:

Ø  It is a SAP specific protocol to provide communication between different systems.

Ø  It is the process of calling Function modules from another system.

Ø  SAP Uses CPIC (Common Programming Interface for Communication) Protocol to transfer data between Systems.

                Types:

                1. Synchronous RFC: In case of this RFC both the Sender/Source and Receiver/Target                      systems should be available while distributing the data. The next part of calling program     isn’t continued until call function is completed.

            2. Asynchronous RFC: In case of this RFC both the Sender/Source and Receiver/Target                    systems should not be available while distributing the data. The next part of calling                            program is continued without completing call function.

            3. Transactional RFC (TRFC): It is almost similar to Asynchronous RFC. The Transactional              RFC is executed only once in an RFC server & save the corresponding data under unique                transaction ID in the Database.

            4. Queued RFC: In case of this RFC the multiple transactional RFC’s are serialized in the                                sequence using the Function module ‘TRFC_SET_QUEUE_NAME’.

Ø  An additional statement ‘Destination’ is used while calling Remote Enabled Functions.

Friday, March 15, 2019

RFC Function Module Create step by step in sap ABAP.


  • RFC Function Module Create step by step in sap ABAP.
  • Go to T-code-SE37
  • At first created function group.
  • If function group not created that time first create function group.
  • At first go to T-code-:-SE37=>Go to=>Function group=>Create Group



  1.  If function group already has created so you can selected your created function group.


  • After that give function module name next select create option.

  • After that select remote enable module option and also give the short text.   Program name and include option automatically created.


  •  Go to import tab


  •  Go to tables tab


BAPI MATERIAL CREATION........................

After that go to Source Code

FUNCTION zrth_pre_ord_chek_list.
*"-----------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     VALUE(I_AUFNR) TYPE  AUFNR
*"  TABLES
*"      GT_FINAL STRUCTURE  ZPP_PRODORD_PRE_CHK
*"      GT_FINAL_AUIT STRUCTURE  ZPPRTHID_VALUE
*"      GT_FINAL_AREA STRUCTURE  ZPP_RTH_OP_AREA
*"------------------------------------------------------
*******************************************************
*              BAPI RELATED DATA                      *
*******************************************************
  
DATA:lv_werks TYPE werks_d.
  
DATAnumber           TYPE  bapi_order_key-order_number,
        collective_order 
TYPE  bapi_order_func_cntrl-collective_order,
        order_objects    
TYPE  bapi_pp_order_objects,
        
return           TYPE  bapireturn1,
        return2          
TYPE  bapiret2.

  
DATA:header           TYPE TABLE OF  bapi_order_header1,
       ls_header        
TYPE bapi_order_header1,
       
position         TYPE TABLE OF  bapi_order_item,
       ls_position      
TYPE bapi_order_item,
       sequence         
TYPE TABLE OF  bapi_order_sequence,
       ls_sequence      
TYPE  bapi_order_sequence,
       operation        
TYPE TABLE OF  bapi_order_operation1,
       ls_operation     
TYPE bapi_order_operation1,
       trigger_point    
TYPE TABLE OF  bapi_order_trigger_point,
       ls_trigger_point 
TYPE bapi_order_trigger_point,
       
component        TYPE TABLE OF  bapi_order_component,
       ls_component     
TYPE bapi_order_component,
       prod_rel_tool    
TYPE TABLE OF  bapi_order_prod_rel_tools,
       ls_prod_rel_tool 
TYPE  bapi_order_prod_rel_tools.

  
DATAi_insplot        TYPE  qibplosnr,
        i_inspoper       
TYPE  qibpvornr,
        lt_inspchar      
TYPE TABLE OF  bapi2045l3,
        ls_inspchar      
TYPE bapi2045l3,
        lt_insppointdata 
TYPE TABLE OF  bapi2045l4,
        ls_insppointdata 
TYPE bapi2045l4.

  
DATAlt_char_results   TYPE TABLE OF  bapi2045d2,
        lt_sample_results 
TYPE TABLE OF  bapi2045d3,
        lt_single_results 
TYPE TABLE OF  bapi2045d4,
        returntable       
TYPE TABLE OF  bapiret2.

*****************************************************
*                       Get Result                  *
*****************************************************
  
IF i_aufnr IS NOT INITIAL.
    
SELECT aufnr
           stlnr
           stlal
      
FROM afko
      
INTO TABLE gt_afko
      
WHERE aufnr EQ i_aufnr.

    
IF gt_afko[] IS NOT INITIAL.
      
SELECT  matnr
              werks
              stlal
              maktx
              stlnr
        
FROM zpp_bom
        
INTO TABLE gt_zpp_bom
*       INTO CORRESPONDING FIELDS OF TABLE gt_final
        
FOR ALL ENTRIES IN gt_afko
        
WHERE stlal  gt_afko-stlal
          
AND stlnr gt_afko-stlnr.

      
SELECT *
        
FROM zpprthid
        
INTO CORRESPONDING FIELDS OF TABLE gt_zppr.

      
IF gt_zppr[] IS NOT INITIAL.
        
SELECT z_op_type_id
               z_op_type_desc
               z_op_value
          
FROM zpprthid_value
          
INTO TABLE gt_zpprval
          
FOR ALL ENTRIES IN gt_zppr
          
WHERE z_op_type_id gt_zppr-z_op_type_id.
      
ENDIF.
    
ENDIF.

*******************************************************
*Call Bapi For Output Details of a Production Order   *
*******************************************************
    
number i_aufnr.
    order_objects
-header         'X'.
    order_objects
-positions      'X'.
*   order_objects-sequences      = 'X'.
    order_objects
-operations     'X'.
*   order_objects-components     = 'X'.
*   order_objects-prod_rel_tools = 'X'.
*   order_objects-trigger_points = 'X'.
*   order_objects-suboperations  = 'X'.

    
CALL FUNCTION 'BAPI_PRODORD_GET_DETAIL'
      
EXPORTING
        
number           number
        collective_order 
collective_order
        order_objects    
order_objects
      
IMPORTING
        
return           return2
      
TABLES
        
header           header
        
position         position
        sequence         
sequence
        operation        
operation
        trigger_point    
trigger_point
        
component        component
        prod_rel_tool    
prod_rel_tool.


    
IF sy-subrc EQ 0.
      
READ TABLE header INTO ls_header INDEX 1.
      
IF sy-subrc EQ 0.
        lv_werks 
ls_header-production_plant.
      
ENDIF.

      
IF lv_werks IS NOT INITIAL.
        
SELECT *
          
FROM zrth_area_id
          
INTO CORRESPONDING FIELDS OF TABLE gt_zarea.

        
IF gt_zarea[] IS NOT INITIAL.
          
SELECT plant
                 matnr
                 zsection
                 z_section_desc
                 z_areaid
                 z_areaname
                 z_checklist_id
                 z_chk_list_ty_desc
                 z_remarks
                 zflag
            
FROM zpp_rth_op_area
            
INTO CORRESPONDING FIELDS OF TABLE gt_zarea_val
            
FOR ALL ENTRIES IN gt_zarea
            
WHERE z_areaid gt_zarea-z_areaid.
        
ENDIF.
      
ENDIF.
    
ENDIF.
  
ENDIF.
*****************************************************
****                   This is order                *
*****************************************************
  
LOOP AT gt_afko INTO gs_afko.
    gs_final
-aufnr  =  gs_afko-aufnr.
    
READ TABLE header INTO ls_header INDEX 1.
    
IF sy-subrc EQ 0.
      gs_final
-plant  ls_header-production_plant.
    
ENDIF.
    
READ TABLE gt_zpp_bom INTO gs_zpp_bom WITH KEY stlal gs_afko-stlal
                                                   stlnr 
gs_afko-stlnr.
    
IF sy-subrc EQ 0.
      gs_final
-material          gs_zpp_bom-matnr.
      gs_final
-material_text  gs_zpp_bom-maktx.
    
ENDIF.
    
APPEND gs_final TO gt_final.
    
CLEARgs_afkogs_final.
  
ENDLOOP.
*****************************************************
****                   This is adit                 *
*****************************************************
  
LOOP AT gt_zpprval INTO gs_zpprval.
    gs_final_auit
-z_op_type_id      gs_zpprval-z_op_type_id.
    gs_final_auit
-z_op_type_desc  gs_zpprval-z_op_type_desc.
    gs_final_auit
-z_op_value          gs_zpprval-z_op_value.
    
APPEND gs_final_auit TO gt_final_auit.
    
CLEAR:gs_final_auit,gs_zpprval.
  
ENDLOOP.
*****************************************************
****                   This is area                 *
*****************************************************
  
LOOP AT gt_zarea_val INTO gs_zarea_val.
    gs_final_area
-plant                     gs_zarea_val-plant.
    gs_final_area
-matnr                    gs_zarea_val-matnr.
    gs_final_area
-zsection                gs_zarea_val-zsection.
    gs_final_area
-z_section_desc     gs_zarea_val-z_section_desc.
    gs_final_area
-z_areaid               gs_zarea_val-z_areaid.
    gs_final_area
-z_areaname         gs_zarea_val-z_areaname.
    gs_final_area
-z_checklist_id     gs_zarea_val-z_checklist_id.
    gs_final_area
-z_chk_list_ty_desc gs_zarea_val-z_chk_list_ty_desc.
    gs_final_area
-z_remarks          gs_zarea_val-z_remarks.
    gs_final_area
-zflag                  gs_zarea_val-zflag.
    
APPEND gs_final_area TO gt_final_area.
    
CLEAR:gs_final_area,gs_zarea_val.
  
ENDLOOP.

ENDFUNCTION.