cancel
Showing results for 
Search instead for 
Did you mean: 

Create a Z extractor writing a code in SE37 calling FM READ_TEXT

Former Member
0 Kudos

Hello,

Could you please help me in the following case?

I need to extract the material sales text.

I have created a structure in SE 11 using the fields VKORG, MATNR, VTWEG, ZSTXT.

Then I am in SE37 building a Z function module, but I do not know how to write in the source code something that calls READ_TEXT properly. What I have for the moment is writen below. Also in the tabs of FM in SE37: Import, Export, Changing, Tables and Exception I am not sure what to fill.

Could you please help?

Thanks & Regards,

Adriana Oliveira

FORM first_call TABLES   P_I_T_SELECT STRUCTURE ZZSALES_TEXT
                         P_I_T_FIELDS STRUCTURE I_T_FIELDS
                USING    P_I_REQUNR
                         P_I_INITFLAG
                         P_I_DSOURCE
                         P_I_MAXSIZE
                CHANGING P_S_S_IF.


DATA : git_memo1 TYPE STANDARD TABLE OF tline,
       g_name1   LIKE thead-tdname,
       gwa_memo1    TYPE tline.



loop at s_matnr.

          CONCATENATE  s_matnr-low g_vkorg c_00 INTO g_name1.


        CALL FUNCTION 'READ_TEXT'
           EXPORTING
                id                      = '0001'
                language                = PT
                name                    = g_name1
                object                  = 'MVKE'
           TABLES
                lines                   = git_memo1
           EXCEPTIONS
                id                      = 1
                language                = 2
                name                    = 3
                not_found               = 4
                object                  = 5
                reference_check         = 6
                wrong_access_to_archive = 7
                OTHERS                  = 8.


               loop at git_memo1 into gwa_memo1.
                write :/0(20) s_matnr-low,25(60) gwa_memo1-TDLINE.
               endloop.
endloop.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Z extractor to load sales text

Former Member
0 Kudos

I would like to answer your question in 2 steps

1) How to create a generic extractor using FM

This weblog will explain you everything

I feel u should start from scratch builing your FM as u need to make a copy of the standard FM make a copy of the standard fm 'RSAX_BIW_GET_DATA_SIMPLE'.

This will solve your questions regarding Import, Export, Changing, Tables and Exception

2) How to use READ_TEXT fm

I'll give u an extract of the code u need.Basically u need to use init_text before u use read_text.

CONCATENATE <f_mvke>-matnr <f_mvke>-vkorg <f_mvke>-vtweg INTO w_name RESPECTING BLANKS.

*Get Sales Text

CALL FUNCTION 'INIT_TEXT'

EXPORTING

ID = '0001'

LANGUAGE = sy-langu

NAME = w_name

OBJECT = 'MVKE'

TABLES

LINES = it_lines

EXCEPTIONS

ID = 1

LANGUAGE = 2

NAME = 3

OBJECT = 4

OTHERS = 5.

IF SY-SUBRC = 0.

REFRESH it_lines.

CALL FUNCTION 'READ_TEXT'

EXPORTING

CLIENT = sy-mandt

ID = '0001'

LANGUAGE = sy-langu

NAME = w_name

OBJECT = 'MVKE'

TABLES

LINES = it_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.

  • Populate the required fields by reading from it_lines

*as it_lines is a table not just a variable

ENDIF.

ENDIF.

Hope this helps you to proceed.

Former Member
0 Kudos

Hello,

I have done the structure and copied the function module using the instructions of the link

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/a0f46157-e1c4-2910-27aa-e3f4a9c8...

However, I do not know where should I include the code you sent. If it is in the first call, fetch next or somewhere else. Please confirm also about how to declare the table which stores the material sales text.

Thanks & Regards,

Adriana Oliveira

Former Member
0 Kudos

Hi Adriana,

if you are able to get a valis resultset using a view I'd suggest to use a view instead of a fm to provide the data to the BI-System. If you would like to extract the data via fm have a look into the RSAX_GET function modules. The examples are quite well documented so you should be able to write your code. If there are open questions, please ask.

Cheers,

Yann

Former Member
0 Kudos

Hello,

Could you please help me to write the code to read the sales text and save it in a Z table in R3? Then I will extract to BI this Z table.

Thanks & Regards,

Adriana Oliveira