[ABAP] learning summary - common statements and functions

[ABAP] learning summary - common statements and functions -----------------------Pointer------------------------ Pointe...

[ABAP] learning summary - common statements and functions

-----------------------Pointer------------------------ Pointer FIELD-SYMBOLS ================================ Loop the inner table into the pointer: 1. FIELD-SYMBOLS:<fs_data> LOOP AT gt_data ASSIGNING <fs_data>. 2. LOOP AT gt_data ASSIGNING FIELD-SYMBOL(<fs_data>). Pointer to allocate component: 1. ASSIGN COMPONENT OF STRUCTURE workspace to < FS > *You can specify < comp > as text or variable. If < comp > is of type C or string, it is the name of the specified component. *If < comp > has any other basic data type, it is converted to type I and refers to the component number. If the allocation is successful, SY-SUBRC is 0, otherwise it is 4. ================================ Usage and comparison of FIELD SYMBOL and TYPE REF TO ================================ TYPE REF TO can only connect to data or object Need to open memory CREATE DATA or CREATE OBJECT 1, Definition The definition of Type Ref To and Field Symbol can specify a specific type or structure, or not. 01 data ref type ref to data 02 03 DATA ref TYPE REF TO ty_ym. "Specify specific structure 04 05 data ref type ref to char20 06 07 field-symbols < FS > type any table 08 09 FIELD-SYMBOLS < FS > TYPE it_ YM. "Specify a specific table 10 11 field symbols < FS > type any. "No specific type or structure is specified, either structure or type 12 13 FIELD-SYMBOLS < FS > TYPE ty_ YM. "Specify specific structure 14 15 field-symbols < FS > type char20 2, Initialization There are two initialization methods for Type Ref To: The first is to use CREATE DATA to dynamically open memory; The second is to use GET REFERENCE OF to point to an existing memory variable The initialization of the Field Symbol can only point to memory variables that already exist. 01 CREATE DATA ref TYPE ty_ym. 02 03 CREATE DATA ref LIKE LINE OF it_ym. 04 05 CREATE DATA ref LIKE wa_ym. 06 07 CREATE DATA ref LIKE ym. If ref is defined to specify a specific TYPE or structure, TYPE can be omitted when creating data. No matter whether ref has a specific type or structure when defining, you must specify a specific type or structure when creating data. It cannot be a generic type such as data. 01 ASSIGN wa_ym to < FS >. "Initialization of field symbol, the effect is equivalent to pointing to wa_ym 02 03 ASSIGN v_ym to < FS >. "Initialization of field symbol, the effect is equivalent to pointing to v_ym 04 05 GET REFERENCE OF wa_ym into Ref. "initialization of type ref to is equivalent to pointing to wa_ym 06 07 GET REFERENCE OF v_ Initialization of YM INTO Ref. "Type Ref To_ YM Must be initialized before using Field Symbol and Type Ref To, otherwise RUNTIME ERROR will occur. 3, Use If a specific type or structure is specified in the first step of definition, Field Symbol and Type Ref To can be used directly; If no type or structure is specified in the first step of definition, then Type Ref To must be assigned to another Field Symbol for indirect use. 1) When specifying a specific type: 01 ref->* = 'abc'. 02 < fs > = 'abc'. 2) When specifying a specific structure: 01 ref - > 02 < fs >-col1 = 'abc'. 3) When no specific type or structure is specified: 01 FIELD-SYMBOLS < FSX > TYPE ty_ym 02 assign ref - > * to < FSX >. "Universal structure 03 < FSX >-col1= 'abc'. 04 05 FIELD-SYMBOLS < FSX > TYPE any. " 06 assign ref - > * to < FSX >. "Universal type 07 < FSX > = 'abc'. 08 09 FIELD-SYMBOLS < FSX > TYPE any. " 10 assign component 'col1' of structure < FS > into < FSX > 11 < FSX > = 'abc'. matters needing attention: Generally speaking, for the convenience of use, the type or structure of Field Symbol or Type Ref To should be specified for direct use later. When using Type Ref To, if it is TYPE REF TO DATA, the Field Symbol will be inevitably used when you want to use this Type Ref To later; In this way, the code is very cumbersome to write. It's better to use Field Symbol in the beginning. However, in the case of a dynamic internal table that does not know the structure in advance, only Type Ref To can be used, combined with Field Symbol; If the Field Symbol is used directly, the Field Symbol cannot be initialized with reference to an existing structure. If the first step is TYPE REF TO DATA, the second step after initialization still needs to specify a specific structure, so it's not as good as specifying the structure in the first step. It is recommended that you use generic definitions only if you do not know the structure in advance. Therefore, either type or structure is specified during definition and initialization, or dynamic inner table or structure cannot be specified in advance; Like the first step TYPE REF TO DATA the second step CREATE DATA ref TYPE ty_ym is not a good way. 4. Differences The main differences found in the usage of Type Ref To and Field Symbol are as follows: 1) Type Ref To can dynamically open memory. In dynamic internal table, it can wait for the program to obtain the structure at runtime before opening memory, and assign it to a Field Symbol. It is impossible to use Field Symbol alone, because the initialization of Field Symbol needs to be "hung" on a known structure. 2) Type Ref To does not have loop at it like Field Symbol_ For the writing method of tab designing < FS >, ref - > * does not point to the inner table data, It is similar to a work area that points to a block of memory, so you need to modify the data to the internal table after you change it. If you don't need the data, you need to clear. Field symbols do not need to consider modify and clear. 3) If < FS1 > = < fs2 > is the value in comparison memory, corresponding to if REF1 - > * = ref2 - >. ================================ -----------------------Internal table------------------------ Delete address duplicates from comparing

Field 2 of field 1 of COMPARING table in delete assistant duplicates from
#According to the field de duplication after COMPARING, sort and use according to these fields first, and keep the first one

SORT inner table from small to large

SORT inner table [BY key 1 Key 2 ] [STABLE] [DESCENDING]
#For rows with the same keyword, the STABLE keyword can keep the original order after sorting
#DESCENDING (from large to small)

Determine whether there is any data in the internal table READ TABLE [index|with key] transportation no fields ================================ READ TABLE [index|with key] transportation no fields It is only to determine whether there is secondary data in the inner table, and it is not necessary to read it into the workspace. If the inner table can read the data, sy subrc = 0 ================================ Statistics inner table row number Description Access the internal standard attribute and assign the number of rows to the variable: description table internal table LINES variable (integer or N) sum number field COLLECT in the inner loop table The COLLECT statement is invoked in the loop, and the same string will gather its numeric field. ================================ LOOP AT gt_data INTO gs_data. COLLECT gs_data INTO gt_sum. ENDLOOP. For example: gt_data data: A Shandong 1 A Shandong 3 B Beijing 4 B Beijing 2 B Beijing 6 A Shandong 2 B Beijing 1 B Beijing 3 After processing gt_sum data: A Shandong 6 B Beijing 16 ================================ String type ` ‘…’ ================================ `... 'is the original string (similar to r' 'in python) '...' is a normal string ================================ -----------------------String------------------------ Concatenate & && ================================ 1. CONCATENATE str1 str2 ...|LINES OF itab INTO result [SEPARATED BY sep] [RESPECTING BLANKS]. The leading spaces of CDNT type will be reserved, and the trailing spaces will be removed, but all spaces of String type will be reserved; For strings of type c, d, n, t, there is a spacing blanks option to use, indicating that trailing spaces will also be reserved. Note: the trailing space will be reserved when using ` ` to assign a String type 2. str = str1 && str2 &&Operator (can break the 255 character limit) 3. str = str1 && str2 &Operator (cannot exceed 255 character limit) ================================ SPLIT string ================================ Take '.' as the separator, and put the separated string into the inner table with only one column, for example: SPLIT str AT '.' INTO TABLE ================================ String to space CONDENSE
================================ CONDENSE <c> [NO-GAPS]. 1. If it is C The type only removes the space in front (because it is fixed length, even if the space in the back is removed, the space will be filled after the left alignment); 2. If it is String Type, the space after will also be removed; 3. Multiple consecutive spaces in the middle of a string are replaced with one space(String So is the type); 4. NO-GAPS: All spaces in the middle of the string are also removed(String So is the type); 5. Left aligned when spaces are removed ================================
SEARCH string search ================================ Search for < C > in < STR > SEARCH <c> FOR <str> <options>. If successful, set SY-SUBRC to 0 and SY-FDPOS to the offset of the string in the field < C >. Otherwise, set SY-SUBRC to 4. ================================ Replace string replace [all occurs of regenx] regex in dobj with new ================================ REPLACE [ALL OCCURRENCES OF REGEX] regex IN dobj WITH new Replace the first [all] regex in dobj with new ================================ String match CO/CN CA/NA CS/NS CP/NP ================================ CO contain only str1 CO str2 Traversal str1, where each character exists in str2, returns true For example: str1 = 'I a' STR2 = 'hub' ----- false str1 = 'ba' str2='hubab' -----true CA contain any str1 CA str2 Traverse str1, and return true if there is a character in str1 in str2 For example: str1 = 'I a' STR2 = 'hub' ----- true CS contain string str1 CS str2 Determine if str1 contains str2. CP contains pattern str1 CP str2 After the comparison, if the result is true, sy fdpos will give the offset information of s2 in s1 str1 = 'aac' str2 = '#aA#c' true str1 = 'aAc' str2 = '#aA#c' true str1 = '123abc123' str2 = '*abc*' sy-fdpos = 3. pattern matching CO / CN contains only or not CA / NA contains any or not any CS / NS contain string or not CP / NP contains pattern or not ================================ CORRESPONDING operation between structures MOVE-CORRESPONDING ADD- SUBTRACT- MULTIPLY- DIVIDE- -----------------------DATA&TYPE------------------------ Define TYPES to INCLUDE
================================ TYPES: BEGIN OF ty_data, fldate TYPE sflight-fldate. INCLUDE TYPE spfli. TYPES: END OF ty_data. ================================
Define constant / RANGE variable / workspace
================================ //Defining constants CONSTANTS:c_cm TYPE slis_formname VALUE 'FRM_USER_COMMAND', c_pf TYPE slis_formname VALUE 'FRM_ALV_STATUS'. //Define range: DATA r_ebeln TYPE RANGE OF Field name WITH HEADER LINE. * r_ebeln-sign = 'I'. * r_ebeln-option = 'EQ'. * r_ebeln-low = ''. * r_ebeln-high = ''. * APPEND r_ebeln. //Define workspace: DATA ... LIKE LINE OF Internal table. ================================
-----------------------Loop control and standard statements------------------------ Global breakpoint BREAK username BREAK user name: the user name will BREAK here every time the program runs Cycle / subprogram control CHECK|EXIT|CONTINUE 1. CHECK condition: if the condition is true, execute the following code, otherwise jump out of the loop (end subroutine in subroutine) 2. EXIT: jump out of loop (end subroutine in subroutine) 3. CONTINUE: jump out of this cycle Exception capture TRY ================================ 1. Syntax: DATA: exref TYPE REF TO CX_ROOT. TRY. Statement block CATCH general exception (CX_SY_ARITHMETIC_ERROR) INTO exref. Exception handling statement block after capture CATCH exception name (example CX_CX_SY_CONVERSION_NO_NUMBER) INTO exref. Exception handling statement block after capture CLEANUP. Clean statement block after any exception is caught ENDTRY. 2. Properties and methods of exref: Textid Property that defines the different text of the exception and also affects the method get_text. Previous Property, which stores the original exception and allows you to build an exception chain get_text Method, which returns the text representation as a string based on the system language of the exception. get_longtext Method, which returns the long variant of the text representation of the exception as a string. get_source_position Method, returns the program name and line number that threw the exception. ================================ CLEAR REFRESH FREE ================================ CLEAR Clear only the table work area. To reset the entire inner table without clearing the table workspace, use clear < itab > [] without freeing up space REFRESH If you add brackets or not, you can only clear the inner table. REFRESH is specifically for clearing the inner table. It cannot clear basic type variables and does not release space FREE At the same time of initialization, the space occupied shall be released. The usage is the same as that of CLEAR ================================ Memory variable EXPORT|IMPORT internal variable = change TO MEMORY ID 'memory name' ================================ 1. ABAP memory variables are similar to local variables, which can be used to communicate between main processes and subprocesses. Different external sessions have different memory spaces Store data in memory: EXPORT internal variable 1 = variable 1 internal variable 2 = variable 2 TO MEMORY ID 'memory name' Read data from memory: IMPORT internal variable 1 = change 3 internal variable 2 = change 4 FROM MEMORY ID 'memory name' Clear all ABAP memory variables: FREE MEMORY. Clear the specified ABAP memory variable: FREE MEMORY ID 'memory name' 2. SAP memory variables are similar to global variables. They are used for communication between external sessions. Different users have different spaces. When users log out, they are cleared Store data in memory: SET PARAMETER ID 'memory name' FIELD variable Read data from memory: GET PARAMETER ID 'memory name' FIELD variable ================================ -----------------------Business module function------------------------ Query inventory / demand list (MD04) 'MD_STOCK_REQUIREMENTS_LIST_API’
================================ DATA: lt_mdpsx TYPE STANDARD TABLE OF mdps WITH HEADER LINE, lt_mdezx TYPE STANDARD TABLE OF mdez WITH HEADER LINE, lt_mdsux TYPE STANDARD TABLE OF mdsu WITH HEADER LINE. DATA: lw_mt61d TYPE mt61d, lw_mdkp TYPE mdkp. CLEAR: lt_mdpsx[],lt_mdezx[],lt_mdsux[]. CALL FUNCTION 'MD_STOCK_REQUIREMENTS_LIST_API' EXPORTING matnr = '704001800243' werks = '3012' IMPORTING e_mt61d = lw_mt61d "Material master record: MRP e_mdkp = lw_mdkp "MRP Header data of voucher TABLES mdpsx = lt_mdpsx "MRP Items in voucher mdezx = lt_mdezx "MRP Individual lines of elements mdsux = lt_mdsux "MRP Element all rows EXCEPTIONS material_plant_not_found = 1 plant_not_found = 2. ================================
Query MRP list (MD06) 'MD_MRP_LIST_API’
================================ DATA: lt_mdezx TYPE STANDARD TABLE OF mdez WITH HEADER LINE. CALL FUNCTION 'MD_MRP_LIST_API' EXPORTING matnr = '704001800243' werks = '3012' TABLES mdezx = lt_mdezx[] EXCEPTIONS mrp_list_not_found = 1 material_plant_not_found = 2 error = 3 OTHERS = 4. ================================
Demand traceability 'MD_PEGGING_NODIALOG’ Get planned order 'BAPI_PLANNEDORDER_GET_DETAIL’ Get production order 'Bapi'_ PRODORD_ GET_ DETAIL’ Get order process information 'BAPI_PROCORD_GET_DETAIL’ -----------------------General function------------------------ Two ALV functions' REUSE_ALV_GRID_DISPLAY’ ‘REUSE_ALV_GRID_DISPLAY_LVC’
================================ 1. 'REUSE_ALV_GRID_DISPLAY' -------------------------DATA------------------------------------ DATA:gt_fieldcat TYPE slis_t_fieldcat_alv, gs_fieldcat TYPE slis_fieldcat_alv, gt_events TYPE slis_t_event WITH HEADER LINE, gs_layout TYPE slis_layout_alv, gt_sort TYPE slis_t_sortinfo_alv, go_grid TYPE REF TO cl_gui_alv_grid. DEFINE add_field. CLEAR gs_fieldcat. gs_fieldcat-no_zero = 'X'. gs_fieldcat-fieldname = &1. "Field name gs_fieldcat-reptext_ddic = &2. "Field text gs_fieldcat-key = &3. "Freeze column gs_fieldcat-edit = &4. "Editable gs_fieldcat-checkbox = &5. "Selection box gs_fieldcat-do_sum = &6. "Summable gs_fieldcat-outputlen = &7. "Field length gs_fieldcat-ref_tabname = &8. "Reference table name gs_fieldcat-ref_fieldname = &9. "Reference field APPEND gs_fieldcat TO gt_fieldcat. END-OF-DEFINITION. -------------------------FORM------------------------------------ FORM frm_display_data. PERFORM frm_set_fieldcat. PERFORM frm_set_layout. PERFORM frm_set_events. PERFORM frm_call_alv_list. ENDFORM. FORM frm_set_fieldcat. * field Field name Freeze optional summing long parameter table add_field 'EBELN' 'Purchase voucher No' ' ' ' ' ' ' '' ' ' 'ZTSD005' 'EBELN'. ENDFORM. FORM frm_set_layout. CLEAR gs_layout. gs_layout-zebra = 'X'."Zebra stripes * gs_layout-info_fieldname = 'COLOR'."colour gs_layout-colwidth_optimize = 'X'."Optimize width * gs_layout-min_linesize = 40."Minimum row width ENDFORM. FORM frm_set_events. * CLEAR gt_events. * gt_events-name = slis_ev_user_command. * gt_events-form = 'FRM_USER_COMMAND'. "Button action * APPEND gt_events. * CLEAR gt_events. gt_events-name = slis_ev_pf_status_set. gt_events-form = 'FRM_PF_STATUS_SET'. "Button settings APPEND gt_events. * gt_events-name = 'CALLER_EXIT'. * gt_events-form = 'FRM_CALLER_EXIT'. * APPEND gt_events. ENDFORM. FORM frm_call_alv_list. CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING i_callback_program = sy-repid it_fieldcat = gt_fieldcat is_layout = gs_layout it_events = gt_events[] it_sort = gt_sort[] i_save = 'A' TABLES t_outtab = gt_data EXCEPTIONS program_error = 1 OTHERS = 2. IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. "Standard error reporting format ENDIF. ENDFORM. FORM frm_pf_status_set USING i_extab TYPE slis_t_extab. SET PF-STATUS 'ZERP_MM105' EXCLUDING i_extab. ENDFORM. 2.'REUSE_ALV_GRID_DISPLAY_LVC' -------------------------DATA------------------------------------ DATA:go_container TYPE REF TO cl_gui_custom_container, go_alvgrid TYPE REF TO cl_gui_alv_grid, gt_fieldcat TYPE lvc_t_fcat, gs_fieldcat TYPE lvc_s_fcat, gs_layout TYPE lvc_s_layo, gs_excluding TYPE ui_func, gt_excluding TYPE ui_functions, gs_event TYPE LINE OF slis_t_event, gt_events TYPE slis_t_event. CLASS lcl_event_receiver DEFINITION. PUBLIC SECTION. METHODS handle_modify FOR EVENT data_changed_finished OF cl_gui_alv_grid IMPORTING e_modified et_good_cells. ENDCLASS. *----------------------------------------------------------------------* * CLASS LCL_EVENT_RECEIVER IMPLEMENTATION *----------------------------------------------------------------------* CLASS lcl_event_receiver IMPLEMENTATION. METHOD handle_modify. CHECK e_modified EQ 'X'. LOOP AT et_good_cells INTO DATA(ls_good_cells). * READ TABLE et_good_cells INTO DATA(ls_good_cells) INDEX 1. READ TABLE gt_items ASSIGNING FIELD-SYMBOL(<fs_items>) INDEX ls_good_cells-row_id. IF ls_good_cells-fieldname EQ 'WERKS1' OR ls_good_cells-fieldname EQ 'LGORT1'. CLEAR gs_items. MOVE-CORRESPONDING <fs_items> TO gs_items. CONDENSE gs_items-werks1 NO-GAPS. CONDENSE gs_items-lgort1 NO-GAPS. CONDENSE gs_items-matnr NO-GAPS. * Factory name PERFORM frm_get_werks_name USING 'GS_ITEMS-WERKS1' CHANGING gs_items-name1. * Take inventory location description PERFORM frm_get_lgort_name USING 'GS_ITEMS-LGORT1' gs_items-werks1 CHANGING gs_items-lgobe1. * Update inventory information PERFORM frm_get_stock_single USING gs_items-matnr gs_items-werks1 gs_items-lgort1 CHANGING gs_items-labst gs_items-lgpbe. MOVE-CORRESPONDING gs_items TO <fs_items>. PERFORM frm_refresh_alv USING go_alvgrid. ENDIF. PERFORM frm_calcu_sum. ENDLOOP. LEAVE TO SCREEN 300. ENDMETHOD. ENDCLASS. "LCL_EVENT_RECEIVER IMPLEMENTATION DATA go_event_receiver TYPE REF TO lcl_event_receiver . -------------------------FORM------------------------------------ FORM frm_display_data . PERFORM frm_set_fieldcat."set up ALV field PERFORM frm_set_layout."set up Layout PERFORM frm_set_events."register ALV event PERFORM frm_call_alv_list."call ALV function ENDFORM. FORM frm_set_fieldcat . FIELD-SYMBOLS <fs_fieldcat> TYPE lvc_s_fcat. CALL FUNCTION 'LVC_FIELDCATALOG_MERGE' EXPORTING i_structure_name = 'ZSMM049' CHANGING ct_fieldcat = gt_fieldcat EXCEPTIONS inconsistent_interface = 1 program_error = 2 OTHERS = 3. READ TABLE gt_fieldcat ASSIGNING <fs_fieldcat> WITH KEY fieldname = 'SEL'. IF sy-subrc EQ 0 . <fs_fieldcat>-edit = 'X'. <fs_fieldcat>-checkbox = 'X'. <fs_fieldcat>-key = 'X'. ENDIF. gs_fieldcat-col_opt = 'A'. MODIFY gt_fieldcat FROM gs_fieldcat TRANSPORTING col_opt WHERE fieldname NE ''. ENDFORM. FORM frm_set_layout . CLEAR gs_layout. gs_layout-zebra = 'X'. * gs_layout-cwidth_opt = 'X'. gs_layout-info_fname = 'COLOR'. gs_layout-stylefname = 'STYLE'. ENDFORM. FORM frm_set_events . CLEAR gt_events. gs_event-name = slis_ev_user_command. gs_event-form = 'FRM_USER_COMMAND'. APPEND gs_event TO gt_events. CLEAR gs_event. gs_event-name = slis_ev_pf_status_set. gs_event-form = 'FRM_PF_STATUS_SET'. APPEND gs_event TO gt_events. CLEAR gs_event. gs_event-name = slis_ev_caller_exit_at_start. gs_event-form = 'FRM_CALLER_EXIT'. APPEND gs_event TO gt_events. ENDFORM. FORM frm_call_alv_list . CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC' EXPORTING i_callback_program = sy-repid is_layout_lvc = gs_layout it_fieldcat_lvc = gt_fieldcat i_save = 'A' it_events = gt_events TABLES t_outtab = gt_data EXCEPTIONS program_error = 1 OTHERS = 2. IF sy-subrc <> 0. * Implement suitable error handling here ENDIF. ENDFORM. FORM frm_user_command USING VALUE(r_ucomm) LIKE sy-ucomm CHANGING rs_selfield TYPE slis_selfield. DATA: lv_valid TYPE c. DATA:es_row_id TYPE lvc_s_row, es_col_id TYPE lvc_s_col, es_row_no TYPE lvc_s_roid. DATA: lv_confirm TYPE boolean, lv_error TYPE boolean. CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR' IMPORTING e_grid = go_alvgrid. CALL METHOD go_alvgrid->check_changed_data IMPORTING e_valid = lv_valid. rs_selfield-refresh = 'X'. * Fixed cursor rs_selfield-row_stable = 'X'. rs_selfield-col_stable = 'X'. CASE r_ucomm. WHEN 'SELALL'."Select all PERFORM frm_sel_all. WHEN 'NOTSEL'."Deselect all PERFORM frm_not_sel. WHEN OTHERS. ENDCASE. ENDFORM. "FRM_USER_COMMAND FORM frm_pf_status_set USING i_extab TYPE slis_t_extab. DATA fcode TYPE TABLE OF sy-ucomm. REFRESH fcode. IF sy-tcode = 'ZEMM49'. APPEND 'DELETE' TO fcode. APPEND 'DELETE' TO i_extab. ENDIF. IF p_ygzcx = 'X'. APPEND 'GOODSMVT' TO fcode. SET PF-STATUS 'ZERP_MM039' EXCLUDING fcode. ELSE. SET PF-STATUS 'ZERP_MM039' EXCLUDING i_extab. ENDIF. ENDFORM. "FRM_PF_STATUS_SET FORM frm_caller_exit USING ls_data TYPE slis_data_caller_exit. CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR' IMPORTING e_grid = go_alvgrid. CREATE OBJECT go_event_receiver. SET HANDLER go_event_receiver->handle_modify49 FOR go_alvgrid. CALL METHOD go_alvgrid->register_edit_event EXPORTING i_event_id = cl_gui_alv_grid=>mc_evt_modified EXCEPTIONS error = 1 OTHERS = 2. ENDFORM. "CALLER_EXIT ================================
Download template file ZCL_ salv=>down_ temp
================================ zcl_salv=>down_temp( EXPORTING i_fname = file name i_objid = file id ). ================================
Button pop up_ TO_ CONFIRM’
================================ CALL FUNCTION 'POPUP_TO_CONFIRM' EXPORTING text_question = 'There are already posting records. Do you want to continue?' text_button_1 = 'yes'(003) text_button_2 = 'no'(004) IMPORTING answer = l_answer EXCEPTIONS text_not_found = 1 OTHERS = 2. IF sy-subrc <> 0. ENDIF. IF l_answer EQ 'A'. "cancel EXIT. ELSEIF l_answer <> '1'. "yes EXIT. ENDIF. ================================
Format / internal and external code CONVERSION_EXIT_ABPSP_OUTPUT’ ‘CONVERSION_EXIT_CUNIT_OUTPUT’ ‘CONVERSION_EXIT_ALPHA_OUTPUT’
================================ # Enter the field, and double-click the routine field in the definition tab to see the conversion function IF gt_data-pspel IS NOT INITIAL. CALL FUNCTION 'CONVERSION_EXIT_ABPSP_OUTPUT' "Function 1. WBS Internal code to external code EXPORTING input = gt_data-pspel "perhaps projn IMPORTING output = gt_data-posid. "(40) TYPE C ENDIF. IF gt_data-posid IS NOT INITIAL. CALL FUNCTION 'CONVERSION_EXIT_ABPSP_INPUT' "Function 2. WBS Outer code to inner code EXPORTING input = gt_data-posid IMPORTING output = gt_data-pspel. "perhaps projn ENDIF. IF gwa_dis-meinh IS NOT INITIAL. CALL FUNCTION 'CONVERSION_EXIT_CUNIT_OUTPUT' "Function 3. Change the outer code of the unit of measurement to the inner code EXPORTING input = gwa_dis-meinh IMPORTING output = gwa_dis-meinh. ENDIF. IF gwa_dis-meinh IS NOT INITIAL. CALL FUNCTION 'CONVERSION_EXIT_CUNIT_INPUT' "Function 4. Conversion of internal code to external code of measurement unit EXPORTING input = gwa_dis-meinh IMPORTING output = gwa_dis-meinh. ENDIF. CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT' "Function 5. Remove leading zeros EXPORTING input = ls_sd002-kunnr IMPORTING output = lv_kunnr. CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL' "Function 6. Date to number: the date format of this function is related to the current login user settings EXPORTING date_external = 'YYYY-MM-DD' IMPORTING date_internal = 00000000 CALL FUNCTION 'CONVERT_DATE_TO_EXTERNAL' "Function 7. The format of the parameter date of this function is related to the setting of the current login user EXPORTING date_internal = 00000000 IMPORTING date_external = 'YYYY-MM-DD' ================================
Write long text 'SAVE_TEXT’
================================ DATA:lt_text LIKE STANDARD TABLE OF tline WITH HEADER LINE. "book DATA:ls_header LIKE thead. DATA:lt_editor TYPE STANDARD TABLE OF ty_editor. CALL FUNCTION 'RH_EDITOR_GET' EXPORTING controlname = 'NOTE' "Custom control name TABLES lines = lt_editor EXCEPTIONS internal_error = 1 OTHERS = 2. ls_header-tdobject = 'ZERP_SD002'. "Text object ls_header-tdname = ztsd006_header-znumber. "Text object name ls_header-tdspras = sy-langu. "language ls_header-tdid = 'Z001'. "text ID ls_header-tdlinesize = '72 '. "Line width MOVE-CORRESPONDING lt_editor TO lt_text[]. CALL FUNCTION 'SAVE_TEXT' EXPORTING client = sy-mandt header = ls_header savemode_direct = 'X' * INSERT = 'X' TABLES lines = lt_text. ================================
Get long text 'READ_TEXT’
================================ DATA:l_name LIKE thead-tdname, lt_lines LIKE STANDARD TABLE OF tline, lwa_lines TYPE tline, lv_maktx(200) TYPE C. IF gs_data-matnr IS NOT INITIAL. CLEAR: l_name,lt_lines,lwa_lines. l_name = gt_data-matnr. CALL FUNCTION 'READ_TEXT' EXPORTING * CLIENT = SY-MANDT id = 'GRUN' "STXL-TDID Read text's id language = sy-langu name = l_name "STXL-TDNAME Reading the value of a text object object = 'MATERIAL' "STXL-TDOBJECT Text object TABLES lines = lt_lines EXCEPTIONS id = 1 language = 2 name = 3 not_found = 4 object = 5 reference_check = 6 wrong_access_to_archive = 7 OTHERS = 8. IF sy-subrc = 0. CLEAR gs_Data-maktx. LOOP AT lt_lines INTO lwa_lines. CONCATENATE lv_maktx lwa_lines-tdline INTO lv_maktx. ENDLOOP. gs_data-maktx = lv_maktx. CLEAR:lwa_lines,lv_maktx. ENDIF. ENDIF. # Get parameter method: 1.Edit mode double click long text or click to enter WORD pattern 2.menu bar"go to"menu,click"Header"option 3.Pop up"identification"Field is ID,"Text object"That is, text object ================================
Field reference 'F4IF_INT_TABLE_VALUE_REQUEST’
================================ CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST' EXPORTING retfield = 'GRUND' value_org = 'S' TABLES value_tab = lt_t157e return_tab = pt_f4 EXCEPTIONS parameter_error = 1 no_values_found = 2 OTHERS = 3. "See code template for details # ALV input reference ================================
Get GUID 'GUID_CREATE’
================================ DATA: l_id32 TYPE guid_32. *DATA: l_id16 TYPE guid. CALL FUNCTION 'GUID_CREATE' IMPORTING ev_guid_32 = l_id32. * ev_guid_16 = l_id16. ================================
Get UUID method Cl_ system_ uuid=>if_ system_ uuid_ static~create_ uuid_ C32
================================ DATA: l_id32 TYPE guid_32. TRY. CALL METHOD cl_system_uuid=>if_system_uuid_static~create_uuid_c32 RECEIVING uuid = l_id32. CATCH cx_uuid_error . MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDTRY. ================================

5 June 2020, 01:55 | Views: 1509

Add new comment

For adding a comment, please log in
or create account

0 comments