Enterprise Resource Planning Blogs by Members
Gain new perspectives and knowledge about enterprise resource planning in blog posts from community members. Share your own comments and ERP insights today!
cancel
Showing results for 
Search instead for 
Did you mean: 
mickaelquesnot
Active Participant
0 Kudos
11,136
https://youtu.be/OauKHsLwQeQ

 

DOWNLOAD PDF VERSION WITH SCREEN SHOTS :

https://icedrive.net/s/APyBWPS1tfDC5XRWt6wgj4DwAWhV

SUBMIT is a keyword in SAP ABAP where you can use to execute an ABAP program within an another ABAP Program. There are multiple variations how you can use SUBMIT statement in SAP ABAP. For example, with different variations of SUBMIT statement syntax, you can define how to set Selection Screen parameters of the calling program, define if you want to execute the ABAP program in background mode, or if you want to save the list results to ABAP Memory.
SUBMIT
Syntax
SUBMIT {rep|(name)} [selscreen_options]
[list_options]
[job_options]
[AND RETURN].
Addition:
... AND RETURN
Effect
The statement SUBMIT calls an executable program. The executable program is executed as described under Flow of an Executable Program. If the called program contains a syntax error, an exception is raised that cannot be handled. The name of the called program can be specified as follows:
 rep
Specified directly and statically as rep.
 (name)
Specified as the content of a parenthesized flat character-like data object name. The data object name must contain the name of the program accessed in uppercase letters. The following can be specified for name:
• Literal or constants

If the data object name is specified as a text field literal or as a constant, it can be evaluated statically and the called program is known as the used object.
• Variable

If the data object name is specified as a variable, it is specified only dynamically and the content is not evaluated statically.
When the statement is executed, name is not evaluated until runtime (in both cases). If the program specified in name is not found, a non-handleable exception is raised.
The additions have the following meaning:
 The additions selscreen_options can be used to determine the selection screen for the program accessed and to supply it with values.
 The additions list_options allow the output medium and the page size to be specified in the basic list for the called program.
 The program can be scheduled for background processing by specifying job_options.
 The addition AND RETURN determines the internal session and the behavior with respect to SAP LUWs.
When the statement SUBMIT is executed, it is followed by an authorization check (using the authorization object S_PROGRAM) for the authorization group specified in the program attributes. The program attribute Start Using Variant is ignored if SUBMIT is used.
Security Note
If the name of a program unit is specified dynamically when it is called, and this name is passed to a program from outside, the result is a serious security risk. Any names passed to a program from outside must be checked thoroughly before being used in calls. The system class CL_ABAP_DYN_PRG, for example, can be used to do this. See Dynamic Calls.
Example
Call program DEMO_PROGRAM_SUBMIT_REP without returning to the calling program.
SUBMIT demo_program_submit_rep.
Addition
... AND RETURN
Effect
The addition AND RETURN determines the object accessed by the runtime environment after the program is called:
 If the addition AND RETURN is not specified, the internal session of the program accessed replaces the internal session of the calling program in the same position in the call sequence, with the current SAP LUW being exited. Once program access is completed, the system returns to before the position from which the calling program was started. The content of the system field sy-calld at SUBMIT is copied by the calling program without AND RETURN.
 The addition AND RETURN starts the executable program in a new internal session of the current call sequence. The session of the calling program and the current SAP LUW are preserved. The called program runs in its own SAP LUW. Once the program call is finished, resumes execution of the program execution is continued after the statement SUBMIT.
The number of internal sessions in a call sequence is restricted to nine. If this is exceeded by SUBMIT ... AND RETURN, the program terminates and the entire call sequence is deleted.
Notes
 SUBMIT does not end the current database LUW, regardless of the addition AND RETURN. A database commit or database rollback in the called program works in exactly the same way as in the current program.
 The statement SUBMIT with the addition AND RETURN opens a new SAP LUW, but it does not open a new database LUW. This means that a database rollback in this SAP LUW can roll back all registration entries made by the statements CALL FUNCTION IN UPDATE TASK or CALL FUNCTION IN BACKGROUND TASK in the tables VB... or ARFCSSTATE and ARFCSDATA. Under certain circumstances, the statement ROLLBACK WORK in the called program can also affect the interrupted SAP LUW. To prevent this, an explicit database commit must be executed before the program is called. This problem does not occur in local updates.
 If there are still procedures registered in the current SAP LUW in the case of SUBMITs without AND RETURN, the SAP LUW exits without calling or rolling back the procedures. Registered update function modules can no longer be executed. In cases like this, therefore, it is advisable to execute the statement COMMIT WORK or ROLLBACK WORK explicitly before the program call.
Example
Call program DEMO_PROGRAM_SUBMIT_REP and return to the calling program.
SUBMIT demo_program_submit_rep AND RETURN.
Exceptions
Non-Handleable Exceptions
 Cause: The specified program was not found.
Runtime error: LOAD_PROGRAM_NOT_FOUND
 Cause: An attempt was made to pass an invalid value to a selection using the addition SIGN.
Runtime error: SUBMIT_WRONG_SIGN
 Cause: The specified program is not a report.
Runtime error: SUBMIT_WRONG_TYPE
 Cause: An attempt was made to pass more than one value to a report parameter.
Runtime error: SUBMIT_IMPORT_ONLY_PARAMETER
 Cause: An attempt was made to use WITH sel IN itab to pass a table without an appropriate layout to a selection.
Runtime error: SUBMIT_IN_ITAB_ILL_STRUCTURE
 Cause: An attempt was made to pass a parameter to the selection screen that cannot be converted to the target field.
Runtime error: SUBMIT_PARAM_NOT_CONVERTIBLE
 Cause: The called program contains a syntax error.
Runtime error: SYNTAX_ERROR

 

Continue
SUBMIT - selscreen_options
SUBMIT - list_options
SUBMIT - job_options
SAP Versions used in the illustration:
• SAP S4 HANA 2021
We need to identify there are two programs when we discuss SUBMIT function.
1. Calling Program: ABAP program which calls or executes the external ABAP program. This is the ABAP program we will implement the SUBMIT statement code.
2. Executed (Called) Program: The Executable program we will execute from the Calling Program.
________________________________________
1.1 Types of ABAP Programs You Can SUBMIT.

Executable ABAP programs are the only programs we can execute using SUBMIT statement. Before coding your calling program you need to first check the type of the program you intend to execute.

1.1.1 Find the Type of the ABAP Program via Transaction se38.
You identify the type of the ABAP program from attributes of the program in transaction se38. Go to transaction se38 and enter the name of the ABAP program and select ‘Attributes’ and choose Display.

 

________________________________________
1.2 Syntax of ABAP SUBMIT Statement.
Syntax of the SUBMIT statement is as follows.
SUBMIT
<Executed (called) program name>
<Selection Screen options>
<Output list options>
<Background job options>
[AND RETURN].

1.2.1 Executed (called) Program Name.
This option defines the name of the Executed (called) program. This program should be of type “Executable” as discussed previously. You define the name of the Executed program as a variable or hard-code the program name. Use an variable to define the program name if the program name should be derived dynamically at run-time.
1.2.2 Selection Screen Options
Executed (called) program might have a Selection Screen. If you require to set the Selection Screen parameters of the Executed program, use this syntax option. Here you can supply the values to the Selection Screen fields of the Executed program from the Calling Program.
1.2.3 Output List Options
Using Output list options, we can define how to handle the output of the program. Using addition, EXPORTING LIST TO MEMORY you can save the list in ABAP memory. Addition TO SAP-SPOOL creates a new Spool request with the Executed output list.
1.2.4 Background Job Options
Addition VIA JOB syntax allow us to execute the program in background mode.
1.2.5 AND RETURN
If you specify AND RETURN, Executed program is started in a new internal session. After the Executed program has run has been completed, Calling Program continue after the SUBMIT statement. We use this addition if we need to sequence the execution of the Calling program and Executed program at run-time.
________________________________________
1.3 Sample ABAP Programs with SUBMIT Statement.
Let’s call the program ZFID_REP_CDSD_ITEM_COND which is used to Update a pricing condition (Condition type ZP04 for example) for an open SD order item in the future. I will call this report for key date as at 31.12.2025.

In this example Calling program name is ‘zcalling_program‘ and the Executed program name is ‘ZFID_REP_CDSD_ITEM_COND‘.

Sales Document Type ZC03
Sales document 82
Condition Type ZP04
Augmentation Oui
Indice 01
Date de fin d'application 31.12.2025
Percentage 5,000
Settle : Yes

1.3.1 SAP Version Sample ABAP Code was Implemented.
• SAP S/4HANA 2021
1.3.2 Create structure for Migration cockpit

 

 

 

 

1.3.3 Create FM for Migration cockpit

Creating a Function Module
You use this procedure to create function modules in the Function Builder.
1. In the Object Navigator (transaction SE80), choose Function Group as the object type.
2. Enter the name of the function group and choose Enter.
The tree structure of the function group appears.
3. In the context menu of the function group, choose Create → Function Module.
The Create Function Module screen appears.
4. In the Function Module field, enter a name for the new function module and in the Short Text field, enter a description for the new function group.
5. Specify the following attributes
Attribute Description
Short text Describes the function module.
Process type Specifies the function type. Choose Normal unless your function is to be run on remote systems or during update tasks.
General data General administration information.
6. Choose Save.
The system automatically creates an include file for your function module. For example, the include file for the first function module in the function group FGRP is called LFGRPU01. The next function modules have include files called LFGRPU02, LFGRPU03, LFGRPU04, and so on.
For more information about include programs, see Understanding Function Module Code.

 

 

Specifying Parameters and Exceptions
1.4 Use
You use this procedure to set parameters and exceptions for your function module. They constitute its interface. The Function Builder has a tab page for each of the following interface components: tables, exceptions, import, export, and changing parameters.
1.5 Procedure
1. In the Object Navigator (transaction SE80), open the function module you want to edit.
2. Enter the required information for each of the parameters (import, changing, export, or table).
Field Description
Parameter Name Name of the parameter for identification purposes.
Type spec. A database field, component of an ABAP Dictionary structure, or an entire ABAP Dictionary structure. This is the same as the ABAP Dictionary field name in the Reference field/reference structure column.
Use this field to create a field based on an ABAP Dictionary field. You should always use a reference structure if the data in the parameter must have the same structure as the reference field (for example, when you want to add new entries to the database).
Associated Type You can enter any system type, either generic or fully typed. For more information, see the Data Types section of the ABAP User Guide.
Default Default value of the parameter. Applies to import and changing parameters only. The system transfers this value to the function module if the caller sets its own value for that parameter.
Reference The parameter reference. Specify this if you want the parameter to be called by reference instead of by value. When a parameter is called by reference, the system points to the original parameter without making a copy of it. The function module works with and, if necessary, alters the original parameter and not a copy. Table parameters are always passed by reference.
3. Enter the exceptions.
The exceptions screen only allows you to enter a text with which the exception can be triggered in the function module.
4. Document the interface on this screen.
On the Documentation screen, you can enter short descriptions of the parameters and exceptions or write full documentation of the entire function module.For more information, see Documenting and Releasing Function Modules
5. Save your entries.

Understanding Function Module Code
1.6 Naming Conventions
When you create a function group, the ABAP Workbench automatically generates a main program, global data, and source code. The system uses the formatSAPL<FGRP> to name the main program where<FRGP> is the name of the function group. For each successive function module in the function group, the system automatically creates an include file and assigns it a name using the following format:L<FGRP>U<NN>.
Tip
In the function group FGRP, the first function module is stored in the include file LFGRPU01. The subsequent function modules are stored in the include files LFGRPU02, LFGRPU03, LFGRPU04, and so on.
1.7 Writing Function Modules
Once you have defined the interface of your function module, you can start writing the source code. In the Object Navigator (transaction SE80), open your function module and choose the Source Code tab page.
Note
The parameters and exceptions of the function module appear as commented lines.
A few features to bear in mind when writing function modules:
Data Handling in Function Modules
 You do not declare export and import parameters in the source code of the function module. The system does this automatically, using an INCLUDE program that inserts a list of the parameters as commented lines in the source code.
 You can declare local data types and objects in function modules in the same way you do that in subroutines.
 You can declare data using the TYPES and DATA statements inL<FRGP>TOP. This data is available to all of function modules in a function group. The system creates the data the first time a function module in the group is called. It always saves the values from the last function module that was called.
Calling Subroutines from Function Modules
You can call various subroutines from function modules.
 You can write internal subroutines, placing them after the ENDFUNCTION statement. These subroutines can be called from all function modules in the group. However, we recommend that you only call them from the function module in which you wrote the function module. This makes your function group easier to understand.
 If you want to create internal subroutines and call them from all of the function modules in the function group<FGRP>, use the special INCLUDE programs L<FGRP>F<XX> .
 You can call any external subroutines from a function module.
Triggering Exceptions
Within a function module, you can address all exceptions by using the names you have defined in the interface. Exceptions are handled either by the system or by the calling program. You define this when you call the function by assigning numeric values to the exceptions that you want to handle yourself. For more information, seeCalling Function Modules From Your Programs.
There are two ABAP statements you can use to trigger exceptions:
Note
RAISE <exception>.
MESSAGE..... RAISING <exception>.
The effect of these statements depends on whether you handle the exception in the calling program or let the system process it:
 If you trigger the exception in the RAISE statement and the calling program has to handle it, the system terminates the processing of the function module and the numeric value assigned to the exception is placed in the system field SY-SUBRC. If the calling program fails to handle the exception, the system triggers a runtime error.
 If you use the MESSAGE... RAISING statement and want the system to handle the exception, no runtime error is generated. The processing continues and the system displays a message with the defined type. To do this, you specify the MESSAGE-ID in the first statement of the include programL<FGRP>TOP. The MESSAGE... RAISINGstatement inserts values in the following system fields:
 SY-MSGID (message ID)
 SY-MSGTY (message type)
 SY-MSGNO (message number)
 SY-MSGV1 to SY-MSGV4 (contents of the fields <F1> to <F4> that are included in the message).
For more information, see the keyword documentation for the MESSAGE statement.
Tip
Suppose we have the following function module:
function my_divide
*"-----------------------------------------------
*"*"Local interface:
*" IMPORTING
*" VALUE(Z1) TYPE F
*" VALUE(M1) TYPE F
*" EXPORTING
*" VALUE(RES) TYPE F
*" EXCEPTIONS
*" DIV_ZERO
*"------------------------------------------------
if n1 eq 0.
raise div_zero.
else.
res = z1 / n1.
endif.
endfunction.
IfN1 is not equal to zero, the module dividesZ1 byN1. Otherwise, it triggers the exception DIV_ZERO.
The MDTEST program calls the MY_DIVIDE function:
report mdtest.
data: result type f.
call function 'MY_DIVIDE'
exporting
z1 = 6
n1 = 4
importing
res = result
exceptions
div_zero = 1
others = 2.
if sy-sybrc eq 0.
write: / 'Result =' , result.
else.
write 'Division by zero'.
endif.
When you run the program, the output is:Result = 1,500000
If you replaceN1 = 4 withN1 = 0 in theEXPORTING list, the program MDTEST processes the exceptionDIV_ZERO by assigning the value 1 toSY-SUBRC. The output is: Division by zero.
You can also use exception classes to raise exceptions. For that purpose, you must have selected the Exception classes indicator.
Tip
function fb_exception_test.
*"---------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" REFERENCE(P1) TYPE I
*" REFERENCE(P2) TYPE I
*" EXPORTING
*" REFERENCE(P3) TYPE I
*" VALUE(P4) TYPE I
*" RAISING
*" CX_SY_ZERODIVIDE
*"---------------------------------------------------------
if p2 = 0.
raise exception type cx_sy_zerodivide.
else.
p3 = p1 / p2.
endif.
endfunction.

 

 

 

Releasing a Function Module
To release a function module, choose Function module → Release →Release.
Note
Check the attributes for a function group to find out who is responsible for the function group. Notify the person responsible when your function module is ready for release. You can also release the function module only internally to other SAP developers.

1.7.1 SUBMIT with WITH SELECTION-TABLE.

Call Report (program) in Background Mode via a Batch Job.
Another important variation is executing a program in background mode. This calling program submit the executed program via a batch job named ‘SUBMIT_BATCHJOB’.
Addition VIA JOB can be only used with AND RETURN.
FUNCTION Z_BAPI_UPDATE_ZSD02.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" VALUE(PV_AUART) TYPE ZBAPIZSD02-AUART DEFAULT 'ZC03'
*" VALUE(PV_PSTYV) TYPE ZBAPIZSD02-PSTYV OPTIONAL
*" VALUE(PV_VBELN) TYPE ZBAPIZSD02-VBELN OPTIONAL
*" VALUE(PV_MATNR) TYPE ZBAPIZSD02-MATNR OPTIONAL
*" VALUE(PV_PRODH) TYPE ZBAPIZSD02-PRODH OPTIONAL
*" VALUE(PV_KSCHL) TYPE ZBAPIZSD02-KSCHL DEFAULT 'ZP04'
*" VALUE(PV_ZZ1_AUGMENTATION) TYPE ZBAPIZSD02-ZZ1_AUGMENTATION
*" DEFAULT 'Oui'
*" VALUE(PV_ZZ1_INDICE) TYPE ZBAPIZSD02-ZZ1_INDICE OPTIONAL
*" VALUE(PV_ZZ1_DATEDEFINDAPPLICAT) TYPE
*" ZBAPIZSD02-ZZ1_DATEDEFINDAPPLICAT OPTIONAL
*" VALUE(PV_PA_XABR) TYPE ZBAPIZSD02-PA_XABR DEFAULT 'X'
*" VALUE(PV_KPROAE) TYPE ZBAPIZSD02-KPROAE OPTIONAL
*" VALUE(PV_SIM) TYPE P06_FLOW_SIMULATION OPTIONAL
*" TABLES
*" ZSD02 STRUCTURE ZBAPIZSD02
*" ZRETURN STRUCTURE BAPIRET2
*"----------------------------------------------------------------------

DATA: LI_SELECTION TYPE TABLE OF RSPARAMS,
LWA_SELECTION TYPE RSPARAMS.

*PV_AUART Sales Document Type
CLEAR LWA_SELECTION.
LWA_SELECTION-SELNAME = 'PV_AUART'.
LWA_SELECTION-KIND = 'S'.
LWA_SELECTION-SIGN = 'I'.
LWA_SELECTION-OPTION = 'EQ'.
LWA_SELECTION-LOW = PV_AUART.
APPEND LWA_SELECTION TO LI_SELECTION.

*PV_PSTYV Sales document item category
CLEAR LWA_SELECTION.
LWA_SELECTION-SELNAME = 'PV_PSTYV'.
LWA_SELECTION-KIND = 'S'.
LWA_SELECTION-SIGN = 'I'.
LWA_SELECTION-OPTION = 'EQ'.
LWA_SELECTION-LOW = PV_PSTYV.
APPEND LWA_SELECTION TO LI_SELECTION.

*PV_VBELN Sales and Distribution Document Number
CLEAR LWA_SELECTION.
LWA_SELECTION-SELNAME = 'PV_VBELN'.
LWA_SELECTION-KIND = 'S'.
LWA_SELECTION-SIGN = 'I'.
LWA_SELECTION-OPTION = 'EQ'.
LWA_SELECTION-LOW = PV_VBELN.
APPEND LWA_SELECTION TO LI_SELECTION.

*PV_KSCHL Condition Type
CLEAR LWA_SELECTION.
LWA_SELECTION-SELNAME = 'PV_KSCHL'.
LWA_SELECTION-KIND = 'S'.
LWA_SELECTION-SIGN = 'I'.
LWA_SELECTION-OPTION = 'EQ'.
LWA_SELECTION-LOW = PV_KSCHL.
APPEND LWA_SELECTION TO LI_SELECTION.

*PV_ZZ1_AUGMENTATION Augmentation
CLEAR LWA_SELECTION.
LWA_SELECTION-SELNAME = 'PV_ZZ1_AUGMENTATION'.
LWA_SELECTION-KIND = 'S'.
LWA_SELECTION-SIGN = 'I'.
LWA_SELECTION-OPTION = 'EQ'.
LWA_SELECTION-LOW = PV_ZZ1_AUGMENTATION.
APPEND LWA_SELECTION TO LI_SELECTION.

*PV_ZZ1_INDICE Indice
CLEAR LWA_SELECTION.
LWA_SELECTION-SELNAME = 'PV_ZZ1_INDICE'.
LWA_SELECTION-KIND = 'S'.
LWA_SELECTION-SIGN = 'I'.
LWA_SELECTION-OPTION = 'EQ'.
LWA_SELECTION-LOW = PV_ZZ1_INDICE.
APPEND LWA_SELECTION TO LI_SELECTION.

*PV_ZZ1_DATEDEFINDAPPLICAT Date de fin d'application
CLEAR LWA_SELECTION.
LWA_SELECTION-SELNAME = 'PV_ZZ1_DATEDEFINDAPPLICAT'.
LWA_SELECTION-KIND = 'S'.
LWA_SELECTION-SIGN = 'I'.
LWA_SELECTION-OPTION = 'EQ'.
LWA_SELECTION-LOW = PV_ZZ1_DATEDEFINDAPPLICAT.
APPEND LWA_SELECTION TO LI_SELECTION.

*PV_KPROAE Percentage price change
CLEAR LWA_SELECTION.
LWA_SELECTION-SELNAME = 'PV_KPROAE'.
LWA_SELECTION-KIND = 'S'.
LWA_SELECTION-SIGN = 'I'.
LWA_SELECTION-OPTION = 'EQ'.
LWA_SELECTION-LOW = PV_KPROAE.
APPEND LWA_SELECTION TO LI_SELECTION.

*PV_PA_XABR Settle Withdrawals and Return Deliveries
CLEAR LWA_SELECTION.
LWA_SELECTION-SELNAME = 'PV_PA_XABR'.
LWA_SELECTION-KIND = 'S'.
LWA_SELECTION-SIGN = 'I'.
LWA_SELECTION-OPTION = 'EQ'.
LWA_SELECTION-LOW = PV_PA_XABR.
APPEND LWA_SELECTION TO LI_SELECTION.

DATA: JOB_NUMBER TYPE TBTCJOB-JOBCOUNT,
JOB_NAME TYPE TBTCJOB-JOBNAME VALUE 'SUBMIT_ZSD02', "Batch job name
PRINT_PARAMETERS TYPE PRI_PARAMS.

*Open batch job
CALL FUNCTION 'JOB_OPEN'
EXPORTING
JOBNAME = JOB_NAME
IMPORTING
JOBCOUNT = JOB_NUMBER
EXCEPTIONS
CANT_CREATE_JOB = 1
INVALID_JOB_DATA = 2
JOBNAME_MISSING = 3
OTHERS = 4.

IF SY-SUBRC = 0.

*Call program in background via a batch job

SUBMIT ZFID_REP_CDSD_ITEM_COND WITH SELECTION-TABLE LI_SELECTION VIA JOB JOB_NAME NUMBER JOB_NUMBER AND RETURN.

IF SY-SUBRC = 0.

*Close batch job
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
JOBCOUNT = JOB_NUMBER
JOBNAME = JOB_NAME
STARTDATE_ = PV_ZZ1_DATEDEFINDAPPLICAT
EXCEPTIONS
CANT_START_IMMEDIATE = 1
INVALID_STARTDATE = 2
JOBNAME_MISSING = 3
JOB_CLOSE_FAILED = 4
JOB_NOSTEPS = 5
JOB_NOTEX = 6
LOCK_FAILED = 7
OTHERS = 8.

ENDIF.

ENDIF.

ENDFUNCTION.

Testing Function Modules
1.8 Use
You use this procedure to test new function modules before releasing them or to examine function modules written by other developers before using these modules in your programs.
1.9 Procedure
1. In the Object Navigator (transaction SE80/se37), open the function module you want to test.
2. In the application toolbar, choose the Test/Execute pushbutton.
The Test Function Module: Initial Screen appears. It displays all of the import and changing parameters of the function module.
3. Fill in values for the relevant IMPORT, CHANGING, and TABLES parameters you want to test.
4. Choose Execute.
The system runs the function module using your input and displays the values of the export parameters.
Note
When you test a function module, the system displays all exceptions. It also calculates the time required to execute the module in microseconds.
Other Test Options
You can also run a test in the ABAP Debugger or create a runtime analysis performance file for a function.
To examine a function module in debugging mode:
1. In the application toolbar, choose the Test/Execute pushbutton.
2. Specify the data you want to transfer from your program to the function module.
3. In the toolbar, choose the Debugging pushbutton.
The system executes the function module in debugging mode. You can step through the code and use all options offered in the ABAP Debugger
To test the performance of a function module:
1. Choose Function Modules → Runtime analysis (transaction SE30).
The system executes the function module and records the performance function in a performance data file.

 

 

 

Go to transaction sm37 to monitor the status of the background job created from the calling program.

Background job created from the SUBMIT calling program.

 

If not specified, default behavior is Batch Job created under the login User and Logon language. You can change the Batch Job user name and language with additions USER and LANGUAGE to the SUBMIT statement.
SUBMIT - Quick reference
Reference
Syntax
SUBMIT {rep|(name)}
[USING SELECTION-SCREEN dynnr]
[VIA SELECTION-SCREEN]
[USING SELECTION-SET variant]
[USING SELECTION-SETS OF PROGRAM prog]
[WITH SELECTION-TABLE rspar]
{ [WITH sel1 { {{EQ|NE|CP|NP|GE|LT|LE|GT} dobj [SIGN sign]}
| {[NOT] BETWEEN dobj1 AND dobj2 [SIGN sign]}
| {IN rtab} }]
[WITH sel2 { {{EQ|NE|CP|NP|GE|LT|LE|GT} dobj [SIGN sign]}
| {[NOT] BETWEEN dobj1 AND dobj2 [SIGN sign]}
| {IN rtab} }]
... }
[WITH FREE SELECTIONS texpr]
[LINE-SIZE width]
[LINE-COUNT page_lines]
{ [EXPORTING LIST TO MEMORY]
| [TO SAP-SPOOL SPOOL PARAMETERS pri_params
[ARCHIVE PARAMETERS arc_params]
WITHOUT SPOOL DYNPRO] }
[[USER user] VIA JOB job NUMBER n [LANGUAGE lang]]
[AND RETURN].
Effect
Calls an executable program.
Additions
 {rep|(name)}
Specifies the program statically as rep or dynamically in name.
 USING SELECTION-SCREEN dynnr
Specifies the selection screen dynnr to be accessed. If nothing is specified, the standard selection screen is called.
 VIA SELECTION-SCREEN
Displays the selection screen called. If nothing is specified, selection screen processing takes place in the background.
 USING SELECTION-SET variant
Supplies the selection screen with values for a selection screen variant variant.
 USING SELECTION-SETS OF PROGRAM prog
Specifies a program prog whose selection screen variants are used.
 WITH SELECTION-TABLE rspar
Supplies the selection screen with values from an internal table rspar of the row type RSPARAMS or RSPARAMS_255.
 WITH sel1 ... WITH sel2 ...
Supplies individual parameters and selection criteria sel1, sel2, ... on the selection screen:

{EQ|NE|CP|NP|GE|LT|LE|GT} dobj [SIGN sign] - Passes a single value dobj with relational operators and a specification for the SIGN column in the selection table.

[NOT] BETWEEN dobj1 AND dobj2 [SIGN sign] - Passes an interval from dobj1 to dobj2 with an optional operator NOT and a specification for the SIGN column in the selection table.

IN rtab - Passes a ranges table rtab.
 WITH FREE SELECTIONS texpr
Supplies the dynamic selection for the selection screen on a logical database with values from an internal table texpr of type RSDS_TEXPR from type group RSDS.
 LINE-SIZE width
Defines the line width in the basic list for the program accessed to width characters.
 LINE-COUNT page_lines
Defines the page length in the basic list for the program accessed to page_lines lines.
 EXPORTING LIST TO MEMORY
Saves the basic list for the program accessed as an internal table of the row type ABAPLIST in the ABAP Memory. Can only be used together with AND RETURN.
 TO SAP-SPOOL
Creates a spool request for the basic list in the program accessed with the following parameters:

SPOOL PARAMETERS pri_params - Spool parameters in a structure pri_params of the type PRI_PARAMS.

ARCHIVE PARAMETERS arc_params - Archiving parameters in a structure arc_params of the type ARC_PARAMS.

WITHOUT SPOOL DYNPRO - Suppresses the spool dialog box.
 [USER user] VIA JOB job NUMBER n [LANGUAGE lang]
Schedules execution of the program accessed as a background task with the number n in the background request job. Can only be used together with AND RETURN. user can be used to specify a user name, and lang to specify the logon language of the background session.
 AND RETURN
Once the program call is finished, resumes execution of the program execution is continued after the statement SUBMIT. Otherwise, the calling program is terminated.

Releasing a Function Module
To release a function module, choose Function module → Release →Release.
Note
Check the attributes for a function group to find out who is responsible for the function group. Notify the person responsible when your function module is ready for release. You can also release the function module only internally to other SAP developers.

 

RFC Migration to BAPI in SAP S/4HANA – Step by Step
2 Business Application Programming Interface (BAPI)
2.1 Use
The SAP business objects stored in the Business Object Repository (BOR) encapsulate their data and processes. External access to the data and processes is only possible by means of specific methods - BAPIs (Business Application Program Interfaces).
A BAPI is defined as a method of an SAP Business Object Type or of an SAP Interface Type.
Example
The functions that are implemented in the SAP business CostCenter object type include, for example, listing all the available cost centers. The business object type CostCenter provides the BAPI GetList() for this purpose.
The BAPIs in the SAP Systems are currently implemented as function modules, which are created and managed in the Function Builder. Each function module underlying a BAPI:
 Supports the Remote Function Call (RFC) protocol
 Has been assigned as a method to a SAP business object type in the Business Object Repository
 Is processed without returning any screen dialogs to the calling application Integration
2.2 Integration
The graphic below shows the relationship between an SAP business object type, its associated BAPIs and its function modules.

Business Object Type with BAPIs and Associated Function Modules
This architecture enables SAP to change the implementation of a BAPI without affecting external applications that are using the BAPI. For information on SAP policy for enhancing BAPIs, and SAP release strategy for BAPIs, see SAP Enhancements to Released BAPIs (CA-BFA).
2.3 Prerequisites
To use a BAPI method to access data in SAP business objects, an application program only needs to 'know' how to call the method. The following information is required:
 The name of the BAPI
 Details of the BAPI interface:
 Import parameters, which contain data to be transferred from the calling program to the BAPI
 Export parameters, which contain data to be transferred from the BAPI back to the calling program
 Import/export (table) parameters for both importing and exporting data
Application programmers can work with SAP business objects and implement their BAPIs without needing to know or consider the underlying implementation and coding details for the object.

3 Advantages of BAPIs
3.1 Use
The section below outlines some of the benefits of using BAPIs to access SAP business objects.
Business Standard
SAP business object types and their BAPIs are the standard for the business contents in the SAP Systems. They enable business functions in the SAP Systems to be integrated with business functions in non-SAP software.
Conforming to Standards
The development of BAPIs is a part of a shared initiative between SAP, customers, partners and leading standards organizations. BAPIs have become a communication standard between business systems.
SAP business object types and their BAPIs can be accessed through object-oriented interface technologies, such as Microsoft COM/DCOM (Component Object Model/Distributed Component Object Model).
SAP business objects conform to the specifications laid down by the Open Applications Group (OAG) and, in cooperation with ObjectBridge from VisualEdge, meet the CORBA guidelines (Common Object Request Broker Architecture) established by the Object Management Group.
Stability and Downward Compatibility
Once a BAPI has been developed and released by SAP, its interface definition and parameters remain stable in the long term. This ensures that an application program is not affected by changes in the underlying SAP software and data.
If BAPIs need to be enhanced, for example by adding optional parameters, SAP can do this without affecting the stability of existing applications. At the same time new applications can benefit from the enhanced functions.
You can find information about SAP’s release strategy for BAPIs at SAP Enhancements to Released BAPIs (CA-BFA).
Object Orientation
As methods of SAP business objects, BAPIs provide access to SAP data and processes. They follow an object-oriented programming model. BAPIs can be called using object-oriented interface technologies such as COM/DCOM. In this way they enable free interaction between SAP and non-SAP software components.
Openness
Using BAPIs, you can access all development platforms which support the SAP Protocol Remote Function Call (RFC).

Step1: Create a Remote (RFC) enabled function module using SE37 transaction. All the parameters of the function module should be ‘Pass by Value’. Reference parameters are not allowed with RFC enabled function module. Save and activate the function module. You will have to define a structure for every parameter in the BAPI. You cannot use the same structures used in existing applications because BAPI structures are frozen when BAPIs are released and then there are restrictions on changing them.

 

 

Step2: Execute Business Object Builder (SWO1). Provide a new name for Object/Interface type and choose the ‘CREATE’ option.

 

 

Step3: Super Type can be left blank if the newly created object type should act as super type. Else a super type can be specified. The program name specified would be created in S/4HANA. BAPI cannot be a local object as they should be transportable. They should be attached to a package and transport request.

 

 

Step4: Execute Edit > Create. Specify the name of the RFC Function Module created in step1.

 

 

Step5: The function module should have property ‘Synchronous’. The system would throw up the message shown below. Select ‘Yes’. The method would be added under the methods node.

Step6: The method must be implemented. This can be achieved by executing the menu option, Change Release Status –> Object Type Component –> to Implemented. After Method is implemented you need to implement Object Type. Select Object type and execute the menu option, Change Release Status –> Object Type –> to Implemented. A success message would be displayed.

 

 

 

Step7: Release the RFC function module using SE37 transaction. Execute the menu option, Function Module –> Release –> Release.
Step8: Release the Object type by executing the menu option Release Status –> Object Type –> to Released.
Step9: Release the method by executing the menu option Release Status –> Object Type Component –> to Released. Save the Object type. The BAPI will now be available in BAPI Explorer (Transaction BAPI).

 

 

 

 

4 Custom Migration Objects using BAPI or Function module
In a SAP S/HANA project is often required to migrate master data from the current system (SAP or Non-SAP) to the new one, or also create massive master data.
Since the first release of SAP S/4HANA, it’s highly recommended by SAP to use
Migrate Your Data - Migration Cockpit tool, for massive master data loading.

 

 

 

 

 

The purpose of this guide is to enhance your knowledge about migration cockpit resources.
SAP delivers plenty of migration objects, such as business partners, cost centers, accounts, conditions records. Nevertheless, there are master data objects which are not supported.
The solution for those cases is customize your own migration object using a BAPI function which maintain the desired master data.
Before starting, it is important to mention that the functional consultant may have the basics of technical knowledge, such as data types and BAPI execution, if necessary, a technical consultant may help on the whole process.
4.1.1 I’m going to use BAPI function module Z_BAPI_UPDATE_ZSD02 to fullfill the requirement of massive update Condition Amount or Percentage in sales orders.

 

Se37

FUNCTION Z_BAPI_UPDATE_ZSD02.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" VALUE(PV_AUART) TYPE ZBAPIZSD02-AUART DEFAULT 'ZC03'
*" VALUE(PV_PSTYV) TYPE ZBAPIZSD02-PSTYV OPTIONAL
*" VALUE(PV_VBELN) TYPE ZBAPIZSD02-VBELN DEFAULT '82'
*" VALUE(PV_MATNR) TYPE ZBAPIZSD02-MATNR OPTIONAL
*" VALUE(PV_PRODH) TYPE ZBAPIZSD02-PRODH OPTIONAL
*" VALUE(PV_KSCHL) TYPE ZBAPIZSD02-KSCHL DEFAULT 'ZP04'
*" VALUE(PV_ZZ1_AUGMENTATION) TYPE ZBAPIZSD02-ZZ1_AUGMENTATION
*" DEFAULT 'Oui'
*" VALUE(PV_ZZ1_INDICE) TYPE ZBAPIZSD02-ZZ1_INDICE DEFAULT '01'
*" VALUE(PV_ZZ1_DATEDEFINDAPPLICAT) TYPE
*" ZBAPIZSD02-ZZ1_DATEDEFINDAPPLICAT DEFAULT '20251231'
*" VALUE(PV_PA_XABR) TYPE ZBAPIZSD02-PA_XABR DEFAULT 'X'
*" VALUE(PV_KPROAE) TYPE ZBAPIZSD02-KPROAE DEFAULT '5'
*" VALUE(PV_SIM) TYPE ZBAPIZSD02-SIM OPTIONAL
*" TABLES
*" ZSD02 STRUCTURE ZBAPIZSD02
*" ZRETURN STRUCTURE BAPIRET2
*"----------------------------------------------------------------------

DATA: LI_SELECTION TYPE TABLE OF RSPARAMS,
LWA_SELECTION TYPE RSPARAMS.

*PV_AUART Sales Document Type
CLEAR LWA_SELECTION.
LWA_SELECTION-SELNAME = 'PV_AUART'.
LWA_SELECTION-KIND = 'S'.
LWA_SELECTION-SIGN = 'I'.
LWA_SELECTION-OPTION = 'EQ'.
LWA_SELECTION-LOW = PV_AUART.
APPEND LWA_SELECTION TO LI_SELECTION.

*PV_PSTYV Sales document item category
CLEAR LWA_SELECTION.
LWA_SELECTION-SELNAME = 'PV_PSTYV'.
LWA_SELECTION-KIND = 'S'.
LWA_SELECTION-SIGN = 'I'.
LWA_SELECTION-OPTION = 'EQ'.
LWA_SELECTION-LOW = PV_PSTYV.
APPEND LWA_SELECTION TO LI_SELECTION.

*PV_VBELN Sales and Distribution Document Number
CLEAR LWA_SELECTION.
LWA_SELECTION-SELNAME = 'PV_VBELN'.
LWA_SELECTION-KIND = 'S'.
LWA_SELECTION-SIGN = 'I'.
LWA_SELECTION-OPTION = 'EQ'.
LWA_SELECTION-LOW = PV_VBELN.
APPEND LWA_SELECTION TO LI_SELECTION.

*PV_KSCHL Condition Type
CLEAR LWA_SELECTION.
LWA_SELECTION-SELNAME = 'PV_KSCHL'.
LWA_SELECTION-KIND = 'S'.
LWA_SELECTION-SIGN = 'I'.
LWA_SELECTION-OPTION = 'EQ'.
LWA_SELECTION-LOW = PV_KSCHL.
APPEND LWA_SELECTION TO LI_SELECTION.

*PV_ZZ1_AUGMENTATION Augmentation
CLEAR LWA_SELECTION.
LWA_SELECTION-SELNAME = 'PV_ZZ1_AUGMENTATION'.
LWA_SELECTION-KIND = 'S'.
LWA_SELECTION-SIGN = 'I'.
LWA_SELECTION-OPTION = 'EQ'.
LWA_SELECTION-LOW = PV_ZZ1_AUGMENTATION.
APPEND LWA_SELECTION TO LI_SELECTION.

*PV_ZZ1_INDICE Indice
CLEAR LWA_SELECTION.
LWA_SELECTION-SELNAME = 'PV_ZZ1_INDICE'.
LWA_SELECTION-KIND = 'S'.
LWA_SELECTION-SIGN = 'I'.
LWA_SELECTION-OPTION = 'EQ'.
LWA_SELECTION-LOW = PV_ZZ1_INDICE.
APPEND LWA_SELECTION TO LI_SELECTION.

*PV_ZZ1_DATEDEFINDAPPLICAT Date de fin d'application
CLEAR LWA_SELECTION.
LWA_SELECTION-SELNAME = 'PV_ZZ1_DATEDEFINDAPPLICAT'.
LWA_SELECTION-KIND = 'S'.
LWA_SELECTION-SIGN = 'I'.
LWA_SELECTION-OPTION = 'EQ'.
LWA_SELECTION-LOW = PV_ZZ1_DATEDEFINDAPPLICAT.
APPEND LWA_SELECTION TO LI_SELECTION.

*PV_KPROAE Percentage price change
CLEAR LWA_SELECTION.
LWA_SELECTION-SELNAME = 'PV_KPROAE'.
LWA_SELECTION-KIND = 'S'.
LWA_SELECTION-SIGN = 'I'.
LWA_SELECTION-OPTION = 'EQ'.
LWA_SELECTION-LOW = PV_KPROAE.
APPEND LWA_SELECTION TO LI_SELECTION.

*PV_PA_XABR Settle Withdrawals and Return Deliveries
CLEAR LWA_SELECTION.
LWA_SELECTION-SELNAME = 'PV_PA_XABR'.
LWA_SELECTION-KIND = 'S'.
LWA_SELECTION-SIGN = 'I'.
LWA_SELECTION-OPTION = 'EQ'.
LWA_SELECTION-LOW = PV_PA_XABR.
APPEND LWA_SELECTION TO LI_SELECTION.

DATA: JOB_NUMBER TYPE TBTCJOB-JOBCOUNT,
JOB_NAME TYPE TBTCJOB-JOBNAME VALUE 'SUBMIT_ZSD02', "Batch job name
PRINT_PARAMETERS TYPE PRI_PARAMS.

CONCATENATE JOB_NAME PV_VBELN INTO JOB_NAME.

IF NOT PV_SIM IS INITIAL.

*Open batch job
CALL FUNCTION 'JOB_OPEN'
EXPORTING
JOBNAME = JOB_NAME
SDLSTRTDT = PV_ZZ1_DATEDEFINDAPPLICAT
IMPORTING
JOBCOUNT = JOB_NUMBER
EXCEPTIONS
CANT_CREATE_JOB = 1
INVALID_JOB_DATA = 2
JOBNAME_MISSING = 3
OTHERS = 4.

IF SY-SUBRC = 0.

*Call program in background via a batch job

SUBMIT ZFID_REP_CDSD_ITEM_COND WITH SELECTION-TABLE LI_SELECTION VIA JOB JOB_NAME NUMBER JOB_NUMBER AND RETURN.

IF SY-SUBRC = 0.

*Close batch job
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
JOBCOUNT = JOB_NUMBER
JOBNAME = JOB_NAME
SDLSTRTDT = PV_ZZ1_DATEDEFINDAPPLICAT
EXCEPTIONS
CANT_START_IMMEDIATE = 1
INVALID_STARTDATE = 2
JOBNAME_MISSING = 3
JOB_CLOSE_FAILED = 4
JOB_NOSTEPS = 5
JOB_NOTEX = 6
LOCK_FAILED = 7
OTHERS = 8.

IF NOT SY-SUBRC IS INITIAL.

CASE SY-SUBRC.

WHEN '1'.

ZRETURN-TYPE = 'E'.
ZRETURN-NUMBER = '507'.
*Cannot Start Immediately
MESSAGE E507(CNV_10940_MSG) INTO ZRETURN-MESSAGE.
APPEND ZRETURN.
EXIT.

WHEN '2'.

ZRETURN-TYPE = 'E'.
ZRETURN-NUMBER = '508'.
*Start dates are invalid
MESSAGE E508(CNV_10940_MSG) INTO ZRETURN-MESSAGE.
APPEND ZRETURN.
EXIT.

WHEN '3'.

ZRETURN-TYPE = 'E'.
ZRETURN-NUMBER = '509'.
*Job Name Missing (Wildcards Allowed)
MESSAGE E509(CNV_10940_MSG) INTO ZRETURN-MESSAGE.
APPEND ZRETURN.
EXIT.

WHEN '4'.

ZRETURN-TYPE = 'E'.
ZRETURN-NUMBER = '510'.
*Error During JOB_CLOSE
MESSAGE E510(CNV_10940_MSG) INTO ZRETURN-MESSAGE.
APPEND ZRETURN.
EXIT.

WHEN '5'.

ZRETURN-TYPE = 'E'.
ZRETURN-NUMBER = '511'.
*Job Specified Does Not Contain Any Steps
MESSAGE E511(CNV_10940_MSG) INTO ZRETURN-MESSAGE.
APPEND ZRETURN.
EXIT.

WHEN '6'.

ZRETURN-TYPE = 'E'.
ZRETURN-NUMBER = '512'.
*Job Specified Does Not Exist
MESSAGE E512(CNV_10940_MSG) INTO ZRETURN-MESSAGE.
APPEND ZRETURN.
EXIT.

WHEN '7'.

ZRETURN-TYPE = 'E'.
ZRETURN-NUMBER = '513'.
*Lock Attempt Failed
MESSAGE E513(CNV_10940_MSG) INTO ZRETURN-MESSAGE.
APPEND ZRETURN.
EXIT.

WHEN OTHERS.

ENDCASE.

ENDIF.

ENDIF.

ENDIF.

ENDIF.

ENDFUNCTION.

Se11

AUART 1 Types AUART CHAR 4 0 0 Sales Document Type
PSTYV 1 Types PSTYV CHAR 4 0 0 Sales document item category
VBELN 1 Types VBELN CHAR 10 0 0 Sales and Distribution Document Number
MATNR 1 Types MATNR CHAR 40 0 0 Material Number
PRODH 1 Types PRODH_D CHAR 18 0 0 Product hierarchy
KSCHL 1 Types KSCHL CHAR 4 0 0 Condition Type
ZZ1_AUGMENTATION 1 Types ZZ1_AUGMENTATION CHAR 3 0 0 Augmentation
ZZ1_INDICE 1 Types ZZ1_INDICE CHAR 10 0 0 Indice
ZZ1_DATEDEFINDAPPLICAT 1 Types ZZ1_DATEDEFINDAPPLICAT DATS 8 0 0 Date de fin d'application
KPROAE 1 Types KPROAE DEC 6 3 0 Percentage price change
PA_XABR 1 Types RM08_KONS_XABR CHAR 1 0 0 Settle Withdrawals and Return Deliveries
SIM 1 Types P06_FLOW_SIMULATION CHAR 1 0 0 Run in simulation mode
1. Once the migration project is set, go to transaction code LTMOM in change mode and create a migration data object as “User defined”:

 

 

2. Define a object name, its description and select option “Function Module”, and click on “Next”:

 

 

3. On the next screen, fullfill the desired BAPI function name.
In section of “Simuation Settings” fullfill with BAPI parameters which controls the db commit command, if applicable.
Click on “Next”:

 

4. The new migration object will be created. Navigating through the paths on the left side, select path “Source Structure”, select “Append structure to Lower Level” and then define a name for the structure:

5. A window on the right side will be displayed where you can define the input file fields, click on “Insert field” button to create.
TIP: Using same field names from BAPI function will help on automatic mapping afterwards.

 

6. After defining source fields, you should map them to the BAPI structures, go to “Structure Mapping” path on the left side and then drag source structure to the BAPI structure, do the same for each field of the source structure.

 

7. Go to “Field Mapping” path and click on “Rule Proposals”, the system will propose automatically field mapping.

In case of fields that the system didn’t match automatically the rule proposal will get in blank, you may define it manually.
Click on Continue.

 

 

8. Now you can generate the migration object, click on “Activate” button.

 

 

9. The activation result will be displayed at bottom of the screen, in case of no errors occurred you may test your custom migration object.

Master data is always a topic in SAP projects which demands time and dedication of the project team.
Using custom migration objects is an option to accelerate process of loading master data which are not covered by standard migration objects.
Add to transport request

 

Result

Test

 

Sm37

 

I hope you enjoyed this topic, and it helps you on your SAP S/4HANA projects.

 
Labels in this area