|
<< Click to Display Table of Contents >> Navigation: All About ABAP Technique > English > Function Module for RFC > Create YFM_RFC_PRACTICE_101 |
Objective |
|
Transaction Code |
|
Support |
|
Create new Structure of "YST_HEADER_101"
▪Open t-Code "SE11" ▪Enter Data Type "YST_HEADER_101"
▪Click " ▪Select "Structure"
▪Fill Short Description "Structure for RFC Report"
▪Add Commponent/Field like this bellow
▪Click " Notes : You can save to Existing Package or Local Object ▪Click " |
1.Open t-Code "SE37"
2.Enter new Function "YFM_RFC_PRACTICE_101"

3.Click "
"
4.Fill Function group with "YFG_MIL" and Short text with "RFC Practice 101"

5.Click "
" to save function
6.Edit and set the Processing type to "Remote-enabled module"

7.Add import variable like this screen capture bellow

8.Add tables variable like this screen capture bellow

9.Add new Source Code, Copy and paste this source code bellow to "Source Code" tab
View Source Code without using "UP TO gv_max_row ROWS"
FUNCTION yfm_rfc_practice_101. *"---------------------------------------------------------------------- *"*"Local interface: *" IMPORTING *" VALUE(GV_MATKL) LIKE MARA-MATKL OPTIONAL *" VALUE(GV_MATNR) LIKE MARA-MATNR OPTIONAL *" VALUE(GV_MAX_ROW) TYPE I DEFAULT 0 *" TABLES *" GI_HEADER STRUCTURE YST_HEADER_101 OPTIONAL *"----------------------------------------------------------------------
DATA: gi_makt TYPE STANDARD TABLE OF makt WITH HEADER LINE, gi_t006a TYPE STANDARD TABLE OF t006a WITH HEADER LINE. DATA: lv_counter TYPE i.
RANGES : lr_matkl FOR mara-matkl, lr_matnr FOR mara-matnr.
IF gv_matkl IS NOT INITIAL. MOVE : gv_matkl TO lr_matkl-low, space TO lr_matkl-high, 'EQ' TO lr_matkl-option, 'I' TO lr_matkl-sign. APPEND lr_matkl. ENDIF.
IF gv_matnr IS NOT INITIAL. MOVE : gv_matnr TO lr_matnr-low, space TO lr_matnr-high, 'EQ' TO lr_matnr-option, 'I' TO lr_matnr-sign. APPEND lr_matnr. ENDIF.
* Collect Master Material SELECT matnr matkl bismt meins INTO CORRESPONDING FIELDS OF TABLE gi_header FROM mara WHERE matkl IN lr_matkl AND matnr IN lr_matnr.
* Collect Material Decription SELECT matnr maktx INTO CORRESPONDING FIELDS OF TABLE gi_makt FROM makt FOR ALL ENTRIES IN gi_header WHERE matnr = gi_header-matnr AND spras = sy-langu.
* Collect Measurement Text SELECT msehi mseht INTO CORRESPONDING FIELDS OF TABLE gi_t006a FROM t006a FOR ALL ENTRIES IN gi_header WHERE msehi = gi_header-meins AND spras = sy-langu.
*Get other requirement information LOOP AT gi_header. * Max Row Checking ADD 1 TO lv_counter. IF lv_counter <= gv_max_row OR gv_max_row = 0. * Get Material Description READ TABLE gi_makt WITH KEY matnr = gi_header-matnr. IF sy-subrc = 0. gi_header-maktx = gi_makt-maktx. ENDIF.
* Get Measurement Text READ TABLE gi_t006a WITH KEY msehi = gi_header-meins. IF sy-subrc = 0. gi_header-mseht = gi_t006a-mseht. ENDIF.
MODIFY gi_header.
ELSE. DELETE gi_header. ENDIF.
ENDLOOP.
ENDFUNCTION. |
View Source Code using "UP TO gv_max_row ROWS"
FUNCTION yfm_rfc_practice_101. *"---------------------------------------------------------------------- *"*"Local interface: *" IMPORTING *" VALUE(GV_MATKL) LIKE MARA-MATKL OPTIONAL *" VALUE(GV_MATNR) LIKE MARA-MATNR OPTIONAL *" VALUE(GV_MAX_ROW) TYPE I DEFAULT 100 *" TABLES *" GI_HEADER STRUCTURE YTA_HEADER_101 OPTIONAL *"----------------------------------------------------------------------
DATA: gi_makt TYPE STANDARD TABLE OF makt WITH HEADER LINE, gi_t006a TYPE STANDARD TABLE OF t006a WITH HEADER LINE. * DATA: lv_counter TYPE i.
RANGES : lr_matkl FOR mara-matkl, lr_matnr FOR mara-matnr.
IF gv_matkl IS NOT INITIAL. MOVE : gv_matkl TO lr_matkl-low, space TO lr_matkl-high, 'EQ' TO lr_matkl-option, 'I' TO lr_matkl-sign. APPEND lr_matkl. ENDIF.
IF gv_matnr IS NOT INITIAL. MOVE : gv_matnr TO lr_matnr-low, space TO lr_matnr-high, 'EQ' TO lr_matnr-option, 'I' TO lr_matnr-sign. APPEND lr_matnr. ENDIF.
* Collect Master Material SELECT matnr matkl bismt meins UP TO gv_max_row ROWS INTO CORRESPONDING FIELDS OF TABLE gi_header FROM mara WHERE matkl IN lr_matkl AND matnr IN lr_matnr.
* Collect Material Decription SELECT matnr maktx INTO CORRESPONDING FIELDS OF TABLE gi_makt FROM makt FOR ALL ENTRIES IN gi_header WHERE matnr = gi_header-matnr AND spras = sy-langu.
* Collect Measurement Text
SELECT msehi mseht INTO CORRESPONDING FIELDS OF TABLE gi_t006a FROM t006a FOR ALL ENTRIES IN gi_header WHERE msehi = gi_header-meins AND spras = sy-langu.
*Get other requirement information
LOOP AT gi_header. * Get Material Description READ TABLE gi_makt WITH KEY matnr = gi_header-matnr. IF sy-subrc = 0. gi_header-maktx = gi_makt-maktx. ENDIF.
* Get Measurement Text READ TABLE gi_t006a WITH KEY msehi = gi_header-meins. IF sy-subrc = 0. gi_header-mseht = gi_t006a-mseht. ENDIF.
MODIFY gi_header.
ENDLOOP.
ENDFUNCTION. |
10.Save and activate the function
▪Input

▪Output

