Views 406
Visitors 255

Create YFM_RFC_PRACTICE_102

Home 
| Top Page | Threads |
Previous  Next

 

Create Structure

Create new Structure of "YST_RANGE_MATKL"

Display Steps

Open t-Code "SE11"
Enter Data Type "YST_RANGE_MATKL"

rfc0042

Click "rfc0002"
Select "Structure"

rfc0043

Fill Short Description "Structure for RANGE for Material Group"

rfc0044

 

Add Commponent/Field like this bellow

rfc0045

 

Click "rfc0007" to save structure

Notes : You can save to Existing Package or Local Object

Click "rfc0008" to active structure

 

Create new Structure of "YST_RANGE_MATNR"

Display Steps

Open t-Code "SE11"
Enter Data Type "YST_RANGE_MATNR"

rfc0046

Click "rfc0002"
Select "Structure"

rfc0047

Fill Short Description "Structure for RANGE for Material Number"

rfc0048

 

Add Commponent/Field like this bellow

rfc0049

 

Click "rfc0007" to save structure

Notes : You can save to Existing Package or Local Object

Click "rfc0008" to active structure

 

Create Function

1.Open t-Code "SE37"
2.Copy Function "YFM_RFC_PRACTICE_101" to "YFM_RFC_PRACTICE_102"

rfc0024

3.Click "rfc0037"
4.Fill to Function module with "YFM_RFC_PRACTICE_102"

rfc0038

5.Click "rfc0039" to copy and save function
6.Click "abap_tutorial0026" to change function
7.Edit the Short text with "RFC Practice 102"

rfc0040

 

8.Delete import variable like this screen capture bellow

Before

rfc0027

 

After

rfc0041

 

9.Add tables variable like this screen capture bellow

rfc0050

 

10.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_102.

*"----------------------------------------------------------------------

*"*"Local interface:

*"  IMPORTING

*"     VALUE(GV_MAX_ROW) TYPE  I DEFAULT 100

*"  TABLES

*"      GI_HEADER STRUCTURE  YTA_HEADER_101 OPTIONAL

*"      GR_MATKL STRUCTURE  YST_RANGE_MATKL OPTIONAL

*"      GR_MATNR STRUCTURE  YST_RANGE_MATNR 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.

 

*  Collect Master Material

  SELECT matnr matkl bismt meins

    INTO CORRESPONDING FIELDS OF TABLE gi_header

  FROM mara

  WHERE

    matkl IN gr_matkl AND

    matnr IN gr_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_102.

*"----------------------------------------------------------------------

*"*"Local interface:

*"  IMPORTING

*"     VALUE(GV_MAX_ROW) TYPE  I DEFAULT 100

*"  TABLES

*"      GI_HEADER STRUCTURE  YTA_HEADER_101 OPTIONAL

*"      GR_MATKL STRUCTURE  YST_RANGE_MATKL OPTIONAL

*"      GR_MATNR STRUCTURE  YST_RANGE_MATNR 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.

 

*  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 gr_matkl AND

    matnr IN gr_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.

11.Save and activate the function

 

Test Run

Input

rfc0051

rfc0052

 

 

Output

rfc0053

 

rfc0054

 

User Threads | New Thread ( Only for Donators )

Threads Last Post Replies Views