Creating a program to fetch customer details from an AS400 system to SAP S/4HANA via RFC (Remote Function Call) involves several steps. Below is a simplified example to illustrate the process. Note that you need the appropriate authorization and system connectivity settings for RFC communication.
Log in to SAP GUI:
Open Transaction SM59:
Choose RFC Connection:
Create RFC Destination:
Enter Connection Details:
Configure Logon & Security:
Additional Parameters:
Test Connection:
Save the RFC Destination:
Activate and register the RFC Destination:
Use the RFC Destination in ABAP Programs:
Create RFC-Enabled Function Module in SAP S/4HANA:
FUNCTION zhr_fm_knb1_fico.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" VALUE(IM_KUNNR) TYPE ZHR_TTY_KNB1 OPTIONAL
*" EXPORTING
*" VALUE(GT_KNB2) TYPE ZHR_TT_KNB1
*" VALUE(EP_MSG) TYPE STRING
*" TABLES
*" GT_KNB1 STRUCTURE KNB1
*"----------------------------------------------------------------------
IF im_kunnr IS NOT INITIAL.
SELECT FROM knb1 FIELDS kunnr,
bukrs,
erdat,
ernam
WHERE kunnr in _KUNNR INTO CORRESPONDING FIELDS OF TABLE _knb2 .
IF gt_knb1 IS INITIAL.
ep_msg = 'No record found'.
ENDIF.
ENDIF.
ENDFUNCTION.
Creating a report program in SAP S/4HANA using the ABAP Editor (SE38) involves defining a report using the Report statement, fetching data from the database, and displaying the results. Below is a simple example of a report program that retrieves and displays data from knb1 table.
*&---------------------------------------------------------------------*
*& Report ZHR_RP_FM
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT ZHR_RP_FM.
DATA: lv_kunnr TYPE kunnr.
*
SELECT-OPTIONS: s_kunnr FOR lv_kunnr.
DATA: lt_range type RANGE OF kunnr.
lt_range = VALUE #( sign = 'I' option = 'BT'
( low = s_kunnr-low )
( high = s_kunnr-high )
).
DATA: lt_knb1 TYPE TABLE OF knb1,
gt_knb1 TYPE TABLE of knb1,
* gs_knb1 TYPE knb1,
lv_msg TYPE string.
START-OF-SELECTION.
*
CALL FUNCTION 'ZHR_FM_KNB1_FICO' DESTINATION 'zhr_a4hana_to_s4hana'
EXPORTING
im_kunnr = lt_range
IMPORTING
GT_KNB2 = gt_knb1 "gs_knb1
EP_MSG = lv_msg
tables
gt_knb1 = lt_knb1
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
IF gt_knb1[] is NOT INITIAL.
cl_demo_output=>display( gt_knb1 ).
ENDIF.
output:
give the input and click on execute button.
provide your user-id for s4hana along with password and click on enter.
it will display the desired output.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
7 | |
6 | |
4 | |
3 | |
3 | |
2 | |
2 | |
2 | |
2 |