Views 728
Visitors 394

Create YFM_RFC_PRACTICE_101

Home 
| Top Page | Threads |
Previous  Next

 

Create Structure

Create new Structure of "YST_HEADER_101"

Display Steps

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

rfc0021

Click "rfc0002"
Select "Structure"

rfc0035

Fill Short Description "Structure for RFC Report"

rfc0022

 

Add Commponent/Field like this bellow

rfc0023

 

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.Enter new Function "YFM_RFC_PRACTICE_101"

rfc0024

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

rfc0025

 

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

rfc0026

 

7.Add import variable like this screen capture bellow

rfc0027

 

8.Add tables variable like this screen capture bellow

rfc0028

 

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

 

Test Run

Input

rfc0032

Output

rfc0033

 

rfc0034

 

User Threads | New Thread ( Only for Donators )

Threads Last Post Replies Views