Volume IV - Cross Application PDF
Volume IV - Cross Application PDF
CROSS APPLICATION
By Irfan
CROSS APPLICATION
Considering his experience in this field, he has turned his interest into
training young candidates. He has trained thousands of students by enlightening
them by his knowledge and experience. He is currently offering excellent
training services in Abap on S/4 Hana. This training provides complete course on
Abap core concepts, RICEF, Abap Oops, Cross Application, Abap new features,
Abap on Hana and Migration (ECC to S/4 Hana), Real-time Projects and complete
preparation for the interview until a person gets selected in his dream job.
P a g e 1 | 56
Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.
CROSS APPLICATION
INDEX
Sl no. Concepts Page no.
5 Extension Idoc 43
P a g e 2 | 56
Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.
CROSS APPLICATION
P a g e 3 | 56
Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.
CROSS APPLICATION
➢ Enter.
➢ Save it (ctrl+S).
➢ Click on ‘connection test’ button to check remote system connectivity
details are correct without errors.
➢ Back (f3).
➢ Click on ‘remote logon’ button to check the connectivity.
Login with Remote system (China system) and create Remote Function
module
➢ Tcode: SE37.
➢ Function module: zrfm1 and click on ‘create’ button.
➢ Function group: ZFGROUP1 (it should be already created).
➢ Short text: Remote Function module.
➢ Click ‘save’ button and enter.
➢ Click on ‘attributes’ tab button.
P a g e 5 | 56
Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.
CROSS APPLICATION
Note:
o If Function group is not active, go to main program and activate it (Ctrl+f3)
then activate function module.
o Reference parameters (address parameters) are not allowed in Remote
function module; therefore, you need to make only pass by value.
Now login with current system (India) and create an executable program
where you call Remote Function of Remote system.
➢ Tcode: SE38.
REPORT ZPRG_ZRFM1.
*Example to call Remote Function synchronously
a2 = 5.
ii) Asynchronous RFC: It is the process in which the calling program (main
thread) calls the remote function (child thread) of remote system and will not
wait for acknowledgement (result) to come from remote system instead it
executes the remaining statements of the calling program.
To work with Asynchronous RFC, we need to consider the following points:
1) Starting New task <task_name>: This statement is used along with call
function statement (main thread) in order to make the calling program
independent of child thread execution as the new task will take the
responsibility of monitoring child process.
2) Receive results from function: This option is used within the definition of
subroutine (form and endform) in order to receive the result from remote
function (child thread) and this subroutine is automatically called by the calling
program (main thread) when child thread execution gets completed.
3) Performing <subr> on end of task: This statement is used along with call
function statement which helps the calling program to automatically call the
subroutine once child process (remote function) gets ended.
4) Wait until <condition>: Main thread execution is very faster than child thread
execution therefore there is a possibility that all the remaining statements of
the calling program (main thread) gets executed and you may not get result from
P a g e 7 | 56
Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.
CROSS APPLICATION
child thread (remote function). Therefore, to avoid this you need to explicitly
use the statement ‘wait until <condition>’.
REPORT ZPRG_ASYNCHRONOUS_RFC.
*Example to call Remote Function Asynchronously
P a g e 8 | 56
Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.
CROSS APPLICATION
ENDIF.
FLAG = 3.
ENDFORM.
Assignment: Create a custom database table in 810 client with mandt field as
first field and get that 810 client data of custom database table to 800 client with
RFC’s.
1) Segment:
o It contains group of fields.
o Standard segments begins with ‘E1’ whereas custom segment begins with ‘Z’
or ‘Y’.
o Tcode to create Segment: WE31.
2) Data element:
o It describes the technical properties of segment field such as data type and
length.
o Tcode to create Idoc type: WE30.
P a g e 9 | 56
Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.
CROSS APPLICATION
Note: Idoc is a collect of records or segments and each segment has different
structure (group of fields).
Logical Message type or Message type: It identifies and interprets the idoc type
with which system generates an idoc and is transferred to receiving system.
Built-in Message types:
P a g e 10 | 56
Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.
CROSS APPLICATION
The Link between Message type and Idoc type: Tcode: WE82
Message type Basic type (Idoc type) Release
MATMAS MATMAS05 740
DEBMAS DEBMAS07 604
CREMAS CREMAS06 617
COSMAS COSMAS01 30A
➢ Enter.
➢ Save to your package (ctrl+S).
➢ Enter.
➢ Select ‘ZIDOCTY1’ and click on ‘create’ button.
➢ Provide the details as below:
➢ Enter.
➢ Save (ctrl+S) to your package.
P a g e 12 | 56
Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.
CROSS APPLICATION
P a g e 13 | 56
Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.
CROSS APPLICATION
P a g e 14 | 56
Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.
CROSS APPLICATION
Note:
o Port is a medium or channel through which communication idoc are
transferred to receivers.
o ALE Architecture uses TRFC port (Transactional Remote Function call).
o TRFC is an asynchronous process that means the sending system sends an
application data to the receiving system and will not wait for
acknowledgment (success/failure), instead it keeps on sending the message
to the receiving systems.
P a g e 15 | 56
Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.
CROSS APPLICATION
P a g e 17 | 56
Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.
CROSS APPLICATION
➢ Save (Ctrl+S).
➢ Go back 2 times.
➢ Click on ii) ‘Assign Logical system to client’ and enter.
➢ Double click on ‘800’ client.
➢ Logical system: SEND_LS.
➢ Save (Ctrl+S).
➢ Save (Ctrl+S).
➢ Go back 2 times.
➢ Click on ‘Assign Logical system to client’ and enter.
➢ Double click on ‘810’ client.
➢ Logical system: REC_LS.
➢ Save (Ctrl+S).
➢ Go back 2 times.
➢ Expand communication.
➢ Click on ‘Create RFC connections’.
➢ Select ‘ABAP Connections’.
➢ Click on ‘create button’ icon.
o RFC Destination: SEND_LS.
o Connection Type: 3.
o Description 1: ALE CONFIG.
P a g e 18 | 56
Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.
CROSS APPLICATION
P a g e 19 | 56
Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.
CROSS APPLICATION
➢ Enter.
➢ Select your Model view-CDM7.
➢ Click on ‘Add message type’ button from application toolbar.
➢ Opens a screen and provide the following details:
➢ Enter.
P a g e 20 | 56
Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.
CROSS APPLICATION
➢ Save it (ctrl+S).
P a g e 21 | 56
Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.
CROSS APPLICATION
➢ Save it (Ctrl+S).
P a g e 22 | 56
Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.
CROSS APPLICATION
➢ Save (Ctrl+S).
➢ Enter.
➢ Select ‘basic data’ and enter.
➢ Save it (Ctrl+S).
P a g e 23 | 56
Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.
CROSS APPLICATION
To Send Material
➢ Tcode: BD10.
➢ Provide the following details:
➢ Enter.
➢ Enter.
P a g e 24 | 56
Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.
CROSS APPLICATION
Now check the material master data (Mat_ale1) in database tables: mara and
makt and also with Tcode: MM03
➢ Tcode: MM03.
➢ Material: MAT_ALE1 and enter.
P a g e 25 | 56
Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.
CROSS APPLICATION
➢ Enter.
➢ Similarly check in Database tables: Mara and Makt.
To create custom idoc’s and transfer the data through custom idoc from
Sending system to Receiving system
Sending System Receiving System
1) Create Custom Database table: 1) Create Custom Database table:
SE11. SE11.
2) Create Custom Idoc. 2)Create Custom Idoc
2(a) Create Custom Segment: WE31. 2(a) Create Custom Segment: WE31.
2(b) Create Custom Idoc type: WE30. 2(b) Create Custom Idoc type: WE30.
3Create Custom Message type: 3) Create Custom Message type:
WE81. WE81.
4) To Link Custom Message type to 4) To Link Custom Message type to
Custom Idoc type: WE82. Custom Idoc type: WE82.
5) To Configure Communication 5) To copy Standard Inbound
Settings: Tcode: Sale. Function module to Custom Inbound
Function module: SE37.
6) To create Customer Distribution 6) To Define characteristics to
Model (CDM): Tcode: BD64. Custom Inbound Function module:
BD51.
7) To create Port: Tcode: WE21. 7) To define Function module as
Inbound and Link it to Custom
Message type: WE57.
8) To generate Outbound Partner 8) To create Custom Process code
Profile: Tcode: WE20. and link it to Custom Message type
and Custom Inbound Function
module: WE42.
P a g e 26 | 56
Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.
CROSS APPLICATION
P a g e 27 | 56
Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.
CROSS APPLICATION
➢ Save (ctrl+S).
P a g e 28 | 56
Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.
CROSS APPLICATION
➢ Enter.
➢ Save it (Ctrl+S).
➢ Save it (Ctrl+S).
➢ Save it (Ctrl+S).
P a g e 29 | 56
Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.
CROSS APPLICATION
➢ Enter.
➢ Select ‘CDM3’ and click on ‘Add message type’ button.
➢ Enter.
➢ Save (Ctrl+S).
7) To create Port:
➢ Tcode: WE21.
➢ Select Transactional RFC.
➢ Click on ‘create’ button.
P a g e 30 | 56
Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.
CROSS APPLICATION
➢ Enter.
➢ Provide the details as below:
➢ Save it (ctrl+S).
P a g e 31 | 56
Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.
CROSS APPLICATION
➢ Save (Ctrl+S).
*to create an input fields to enter employee number,message type and logic
al system
PARAMETERS:p_eno like zyemp-eno,
p_msgty type edi_mestyp,
p_logsys type logsys.
START-OF-SELECTION.
perform fill_ctrl_record.
perform preprare_master_idoc.
PERFORM generate_comm_idoc.
*&---------------------------------------------------------------------*
*& Form FILL_CTRL_RECORD
*&---------------------------------------------------------------------*
FORM FILL_CTRL_RECORD .
P a g e 33 | 56
Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.
CROSS APPLICATION
ENDFORM.
*&---------------------------------------------------------------------*
*& Form PREPRARE_MASTER_IDOC
*&---------------------------------------------------------------------*
FORM PREPRARE_MASTER_IDOC .
ENDFORM.
*&---------------------------------------------------------------------*
*& Form GENERATE_COMM_IDOC
*&---------------------------------------------------------------------*
FORM GENERATE_COMM_IDOC .
P a g e 34 | 56
Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.
CROSS APPLICATION
ERROR_IN_IDOC_DATA =3
SENDING_LOGICAL_SYSTEM_UNKNOWN = 4
OTHERS = 5.
IF SY-SUBRC = 0.
* commit work.
* to find no. of records in communication idoc(it_comm_idoc)
DESCRIBE TABLE it_comm_idoc.
write:/ sy-tfill, ' Communication Idocs generated'.
else.
MESSAGE id sy-msgid TYPE sy-msgty NUMBER sy-msgno with sy-
msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
ENDFORM.
➢ Click on ‘copy’.
➢ Enter.
➢ Click on ‘change’ button.
➢ Click on ‘source code’.
Note: Delete the entire code except function and endfunction.
FUNCTION ZIDOC_INPUT_EMP.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" VALUE(INPUT_METHOD) LIKE BDWFAP_PAR-INPUTMETHD
*" VALUE(MASS_PROCESSING) LIKE BDWFAP_PAR-MASS_PROC
*" VALUE(PI_XD99_USED) TYPE CHAR1 DEFAULT SPACE
*" VALUE(PI_KNVK_SPECIAL) TYPE CHAR1 DEFAULT SPACE
*" EXPORTING
*" VALUE(WORKFLOW_RESULT) LIKE BDWFAP_PAR-RESULT
*" VALUE(APPLICATION_VARIABLE) LIKE BDWFAP_PAR-APPL_VAR
*" VALUE(IN_UPDATE_TASK) LIKE BDWFAP_PAR-UPDATETASK
*" VALUE(CALL_TRANSACTION_DONE) LIKE BDWFAP_PAR-CALLTRANS
*" TABLES
*" IDOC_CONTRL STRUCTURE EDIDC
P a g e 36 | 56
Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.
CROSS APPLICATION
loop at idoc_data.
case idoc_data-segnam.
when 'ZYSEG1'.
WA_SEGEMP = IDOC_DATA-SDATA.
MOVE-CORRESPONDING WA_SEGEMP TO ZYEMP.
** TO INSERT DATA INTO CUSTOM DBTABLE -ZYEMP
MODIFY ZYEMP FROM ZYEMP.
IF SY-SUBRC = 0.
IDOC_STATUS-DOCNUM = IDOC_DATA-DOCNUM.
IDOC_STATUS-STATUS = '53'.
IDOC_STATUS-MSGTY = 'S'.
IDOC_STATUS-MSGID = 'ZMSG1'.
IDOC_STATUS-MSGNO = '010'.
IDOC_STATUS-MSGV1 = ZYEMP-ENO.
else.
IDOC_STATUS-DOCNUM = IDOC_DATA-DOCNUM.
IDOC_STATUS-STATUS = '51'.
IDOC_STATUS-MSGTY = 'E'.
IDOC_STATUS-MSGID = 'ZMSG1'.
IDOC_STATUS-MSGNO = '011'.
IDOC_STATUS-MSGV1 = ZYEMP-ENO.
ENDIF.
P a g e 37 | 56
Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.
CROSS APPLICATION
APPEND IDOC_STATUS.
ENDCASE.
ENDLOOP.
ENDFUNCTION.
➢ Activate (ctrl+F3).
➢ Save it (ctrl+S).
➢ Save (Ctrl+S).
P a g e 38 | 56
Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.
CROSS APPLICATION
8) To create Custom Process code and link it to Custom Message type and
Custom Inbound Function module:
➢ Tcode: WE42.
➢ Click on ‘change’ button.
➢ Click on ‘new entries’ button.
➢ Provide the details as below:
P a g e 39 | 56
Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.
CROSS APPLICATION
➢ Save it (ctrl+S).
P a g e 40 | 56
Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.
CROSS APPLICATION
➢ Save it (Ctrl+S).
➢ Execute (F8).
➔ Message: Send Employee data.
➔ Communication Idocs generated.
➢ Check the idoc status: WE02.
P a g e 41 | 56
Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.
CROSS APPLICATION
P a g e 42 | 56
Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.
CROSS APPLICATION
Extension Idoc: It is the concept in which along with Standard application data
you can send or transfer custom data (‘Z’ fields) to the Receiving System.
Note: Custom fields cannot be added directly in the idoc type (DEBMAS06)
instead you need to create custom segment with custom fields and then add
this custom segment to custom idoc type.
P a g e 43 | 56
Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.
CROSS APPLICATION
➢ Activate (Ctrl+F3).
P a g e 44 | 56
Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.
CROSS APPLICATION
➢ Enter.
P a g e 45 | 56
Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.
CROSS APPLICATION
➢ Enter.
➢ Save (Ctrl+S) to your package.
Step-4: To link Extension Idoc type to Standard Message type (DEBMAS) and
Basic type (Idoc type-DEBMAS06).
➢ Tcode: WE82.
➢ Click on ‘Change’ button.
➢ Enter.
➢ Click on ‘New entries’ button.
➢ Enter.
➢ Save (Ctrl+S) to your package.
Login with Receiving System
Note: Create custom fields with the same name, data type, length, custom
segment, Extension idoc same as Sending system.
Step1: To add custom fields to standard database table KNA1 using Append
structure.
➢ Tcode: SE11.
Step-2: To create Custom Segment:
➢ Tcode: WE31.
Step-3: To create Extension Idoc
➢ Tcode: WE30.
P a g e 46 | 56
Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.
CROSS APPLICATION
Step-4: To link Extension Idoc type to Standard Message type (DEBMAS) and
Basic type (Idoc type-DEBMAS06).
➢ Tcode: WE82.
➢ Note: All the 4 steps same as above, you need to repeat in the Receiving
system.
Login with Sending System
Note: BD12 is the Standard Transaction which is used to Send Customer master
data from Sending system to Receiving system but to send the custom segment
data (‘z’ fields data of kna1) along with standard data, you need to add custom
functionality in the standard transaction BD12 and this is achieved with the help
of enhancement.
➢ Package: VSV.
➢ Enter.
Exit name Short text.
VSV00001 User exit Customer and vendor
distribution Receipt/issue.
VSV00002 Read filter objects for vendor master.
VSV00003 Read filter objects for customer
master.
➢ Enhancement: VSV00001.
➢ Click on ‘Display’ button.
➢ Click on ‘components’ button.
P a g e 47 | 56
Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.
CROSS APPLICATION
Note:
o EXIT_SAPLVV01_001: This Exit need to be implemented in Sending system
which will fill custom segment and send it to receiver.
o EXIT_SAPLVV02_001: This Exit need to be implemented in Receiving system
which will read custom segment and post it to standard database table
(Kna1).
Include ZXVSVU01
*to create work area
data wa_zkna1 type ZAKNA1.
*to create segment work area of type segment:ZCSEG1
P a g e 48 | 56
Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.
CROSS APPLICATION
ENDCASE.
➢ Activate (ctrl+F3).
To configure Outbound Process for the message type -Debmas for Extension
idoc
Step-1: To configure Communication Settings: Tcode: Sale.
i) Define Logical system.
ii) Assign Logical system to Client.
iii) Create RFC connection.
Step-2: To create Customer Distribution Model (CDM): Tcode: BD64.
➢ Click on ‘change’ button.
➢ Click on ‘create model view’ button.
o Short text: customer distribution model.
o Technical name: CDM9.
➢ Enter.
➢ Select ‘CDM9’ and click on ‘Add message type’ button.
P a g e 49 | 56
Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.
CROSS APPLICATION
➢ Enter.
➢ Save it (Ctrl+S).
➢ Enter.
➢ Save it (Ctrl+S).
P a g e 50 | 56
Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.
CROSS APPLICATION
Step-4: To create Outbound Partner profile for message type: Debmas and
Extension idoc
➢ Tcode: WE20.
➢ Note: If the partner already exists, we can use it.
➢ Expand partner type-LS and select your existing partner-REC_LS.
➢ In Outbound Parameters.
➢ Save it (Ctrl+S).
Login with Receiving System
To Configure Inbound Process for the message type -Debmas for extension
idoc
Step-1: To configure Communication Settings: Tcode: Sale.
➢ i) Define Logical system.
➢ ii) Assign Logical system to Client.
P a g e 51 | 56
Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.
CROSS APPLICATION
➢ Save it (Ctrl+S).
P a g e 53 | 56
Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.
CROSS APPLICATION
LOOP AT IDOC_DATA.
CaSE IDOC_DATA-SEGNAM.
WHEN 'E1KNA1M'.
WA_E1KNA1M = IDOC_DATA-SDATA.
WHEN 'ZCSEG1'.
WA_ZSEG1 = IDOC_DATA-SDATA.
MOVE-CORRESPONDING WA_ZSEG1 TO WA_ZAKNA1.
UPDATE KNA1 SET ZZKUNNR = WA_ZAKNA1-
ZZKUNNR ZZLEGSYSNO = WA_ZAKNA1-
ZZLEGSYSNO WHERE KUNNR = WA_E1KNA1M-KUNNR.
ENDCASE.
ENDLOOP.
➢ Activate (Ctrl+F3).
P a g e 54 | 56
Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.
CROSS APPLICATION
P a g e 55 | 56
Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.
CROSS APPLICATION
➢ Enter.
➢ Enter.
➢ Again, check Idoc Status: Tcode: WE02.
➢ Then check in Standard database table Kna1 and custom fields added to it.
P a g e 56 | 56
Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.