ABAP-function

miscellaneous notes

 If gt_a is empty, fetch all data. [Refer to where field in s_field].

 Refresh itab. Or refresh itab[]. Both clear the inner table row.

free itab is to release the memory area.

 The tables statement declares a structure with the same name as a database table.

[Important!] Because I always forget.

 from subroutine name using value(p_matnr). Indicates that only the value passed in will not change the original value (gv_matnr).

remove extra spaces

 Assign the parameter ID to the value of mat as lv_value

The program jumps to the interface of mm03 transaction code 

 get parameter ID 'MAT' field lv_value.

Assign parameter ID to the value in mat to lv_value.

Usage of SUM

sum can only be used in the loop cycle, generally used in conjunction with at-endat

1  1
2  8
3  27
在这个内表中使用sum
at end of col1.
write:col1, col2."省力写法别学
endat.
1 1
2 8
3 27
在这个内表中使用sum
loop at itab into line.
sum.
write:line-col1,line-col2.
endloop 

function

Fields in the function group refers to the global variables defined in the include. 

Call the from subroutine in include in the function module.

Subroutines automatically record subroutines in function groups.

Select the subroutine name and drag it directly to call it.

Optional in the function module indicates whether it is optional, if it is checked, it is optional, and if it is not checked, it is not optional

Pass value means pass value or pass parameter.

Check-Activate-Execute-Description List-Information-Delete-Copy-Rename-Reassign. 

The variable starting with I_ in import is the variable IS_ starting with the structure IT_ starting with the internal table. 

Function module documentation is used to view function description and parameter overview 

Exception represents a possible error in a function.

It means that if a function module calls and modifies the global variable A (in the function group), it will make the function module of the same function group 

When calling A again, it is the changed A.

 

 RAISE NO_ZERO. Prompt exception.

 

 

 

 

 

 Function mode call (standard case)

 

 

Prompt that we should handle the exception. 

When such exception checking is not performed in the function, it will: 

 The program prompts a logic error.

When writing and calling functions, possible exceptions should be caught and handled.

 

 

 

The value of case sy-subrc is 1 or 2... These values ​​are derived from abnormal values, which can prompt different messages or perform different processing through different values.

  When an exception is caught, both the program and the function will terminate. (For example, the primary key of the database table cannot insert the same data)

If you can find the mandt (primary key) in the primary key but it is generally not used, there should be a matnr field in the incoming parameter structure

This passage means to find the same zschool field in is_school (input function parameter) and put it into ls_school

Here sy-subrc is related to the search statement, when the query is found (that is, ls_school is not empty), it is 0, otherwise it is not 0.

 

Here IS_SCHOOL refers to a field structure without mandt.  

 

  The relationship between function groups and function modules

When a function module is called, its function group will be called at the same time.

 

 Parameters are passed in and out when the function is called, and there is no type coercion.

 

 

 

 Global variables in function groups are shared.

 How to keep the value of the local variable released without leaving the subroutine (or function), just define it as static

 

 

 System variables can also be modified in the program.

 The value of SY-BATCH is 'X' when it is running in the background. It is empty when it is running in the foreground.

Click the F8 execution button to execute in the foreground

 Click the F9 button to execute in the background

Click √.

Click the Now button.

 

Click Save. 

 

Guess you like

Origin blog.csdn.net/qq_53645728/article/details/131015148