cancel
Showing results for 
Search instead for 
Did you mean: 

Urgent: Problems in Generic Extraction by Function Module

Former Member
0 Kudos

Hi BW Gurus,

I am new to SDN and also new to generic extraction using function module. My requirement is to extract long text(142 char) from CRM to BW as the text is not stored in database table I used function module read_text with in another ZXXX function module copy of (RSAX_BIW_GET_DATA_SIMPLE). In my extract structure I used GUID(char,32), Langu, long text(142 char) and 2 placeholders. Text can be extracted by passing STXH table fields(Tdname, Tdid, Tdobject, Tdspars) to read_text as parameters and i also need to use CRMD_ORDERADM_H field GUID(32 char) to compare 1st 32 chars of tdname(70 char) with Guid to select Guids and loop thru this Guids and for each Guid i need to append lines of text to e_t_data but as i donot know ABAP i unable to write the code for this. Through my friends help i wrote code when i check in RSA3 it is displaying the text but when i replicate into BW and load into data target in monitor the status is red with records initially but afterwards it will be red status again with 0 from 0 records for initial load again.when i check on job logs the errors i have are:

The background job has created a job log file of 2Gb size and it is currently on a infinite loop writing entries into the SAP System Log that it cannot write to the Job log file due to “Error 22 for write/read access to a file” this is because of the datasource i have created. Please find my Function module and if anyone would please correct FM and send me that will be really great.I appreciate it in advance.

MY Function Module is:

FUNCTION Z_CRMORDERH_STR_TXT.

*"----


""Local Interface:

*" IMPORTING

*" VALUE(I_REQUNR) TYPE SRSC_S_IF_SIMPLE-REQUNR

*" VALUE(I_DSOURCE) TYPE SRSC_S_IF_SIMPLE-DSOURCE OPTIONAL

*" VALUE(I_MAXSIZE) TYPE SRSC_S_IF_SIMPLE-MAXSIZE OPTIONAL

*" VALUE(I_INITFLAG) TYPE SRSC_S_IF_SIMPLE-INITFLAG OPTIONAL

*" VALUE(I_READ_ONLY) TYPE SRSC_S_IF_SIMPLE-READONLY OPTIONAL

*" VALUE(I_REMOTE_CALL) TYPE SBIWA_FLAG DEFAULT SBIWA_C_FLAG_OFF

*" TABLES

*" I_T_SELECT TYPE SRSC_S_IF_SIMPLE-T_SELECT OPTIONAL

*" I_T_FIELDS TYPE SRSC_S_IF_SIMPLE-T_FIELDS OPTIONAL

*" E_T_DATA STRUCTURE YCRM_TEXT_STR OPTIONAL

*" EXCEPTIONS

*" NO_MORE_DATA

*" ERROR_PASSED_TO_MESS_HANDLER

*"----


***" EXCEPTIONS NO_MORE_DATA

*" ERROR_PASSED_TO_MESS_HANDLER

*"----


Tables: CRMD_ORDERADM_H, STXH.

***

        • Auxiliary Selection criteria structure

data: l_s_select type srsc_s_select.

***

        • Maximum number of lines for DB table

Statics: s_s_if type srsc_s_if_simple,

***

        • counter

s_counter_datapakid like sy-tabix,

***

        • Cursor

s_cursor type cursor.

***

data: i_crmtext type standard table of TLINE .

*

types: begin of xsreph ,

GUID type CRMD_ORDERADM_H-guid,

end of xsreph.

data: i_guid type standard table of xsreph.

  • data: I_TEXT type STXH-TDNAME.

*

**

data: xempl like YCRM_TEXT_STR occurs 0 with header line.

**

data: t_tab like dd03l-tabname.

***

      • Select ranges

ranges: l_r_guid for CRMD_ORDERADM_H-guid.

      • l_r_connid for sflight-connid.

**

        • Initialization mode (first call by SAPI) or data transfer mode

        • (following calls) ?

if i_initflag = sbiwa_c_flag_on.

**

**************************************************************************

        • Initialization: check input parameters

        • buffer input parameters

        • prepare data selection

***************************************************************************

***

        • Check DataSource validity

case i_dsource.

when 'yCRM_TEXT'. " for S_SREPH1

when others.

if 1 = 2. message e009(r3). endif.

  • this is a typical log call. Please write every error message like this

log_write 'E' "message type

'R3' "message class

'009' "message number

i_dsource "message variable 1

' '. "message variable 2

raise error_passed_to_mess_handler.

endcase.

**

append lines of i_t_select to s_s_if-t_select.

**

        • Fill parameter buffer for data extraction calls

s_s_if-requnr = i_requnr.

s_s_if-dsource = i_dsource.

s_s_if-maxsize = i_maxsize.

***

        • Fill field list table for an optimized select statement

        • (in case that there is no 1:1 relation between InfoSource fields

        • and database table fields this may be far from beeing trivial)

append lines of i_t_fields to s_s_if-t_fields.

***

        • we will do our selection based on what is in the p table for the

        • infoobject

***

else. "Initialization mode or data extraction ?

***

***************************************************************************

        • Data transfer: First Call OPEN CURSOR + FETCH

        • Following Calls FETCH only

***************************************************************************

**

      • First data package -> OPEN CURSOR

if s_counter_datapakid = 0.

**

      • Fill range tables BW will only pass down simple selection criteria

      • of the type SIGN = 'I' and OPTION = 'EQ' or OPTION = 'BT'.

**

LOOP AT S_S_IF-T_SELECT INTO L_S_SELECT WHERE FIELDNM = 'GUID'.

MOVE-CORRESPONDING L_S_SELECT TO L_R_GUID.

APPEND L_R_GUID.

ENDLOOP.

case i_dsource.

when 'YCRM_TEXT'. " for S_SREPH1

t_tab = 'CRMD_ORDERADM_H'.

endcase.

select GUID

from (t_tab)

into table i_guid where PROCESS_TYPE = 'ZACI' and ( OBJECT_ID < '0000000042').

  • select tdname from stxh into i_text where tdobject = 'TEXT'.

    • if sy-subrc ne 0.

    • message e009(r3).

    • this is a typical log call. Please write every error message like this

    • log_write 'E' "message type

    • 'R3' "message class

    • '009' "message number

    • i_dsource "message variable 1

    • 'No master data found'. "message variable 2

    • raise error_passed_to_mess_handler.

    • endif.

***

        • Determine number of database records to be read per FETCH statement

        • from input parameter I_MAXSIZE. If there is a one to one relation

        • between DataSource table lines and database entries, this is trivial.

        • In other cases, it may be impossible and some estimated value has to

        • be determined.

  • open cursor with hold s_cursor for

  • select (s_s_if-t_fields) from CRMD_ORDERADM_H

  • where GUID in L_R_GUID .

*

ENDIF.

***

***

        • Fetch records into interface table.

          • named E_T_'Name of extract structure'.

  • fetch next cursor s_cursor

  • appending corresponding fields

  • of table e_t_data

  • package size s_s_if-maxsize.

*

  • IF SY-SUBRC <> 0.

  • CLOSE CURSOR S_CURSOR.

  • RAISE NO_MORE_DATA.

  • ENDIF.

*

        • as we are doing this only once can use the select statement.

***data: crmtext like tline occurs 0 with header line.

**data: i_crmtext type standard table of TLINE.

**data: i_guid type standard table of xsreph.

data: l_guid type THEAD-TDNAME.

data: st_guid type xsreph.

data: st_crmtext type TLINE.

data: lan type THEAD-TDSPRAS.

lan = 'E'.

loop at i_guid into st_guid.

l_guid = st_guid-guid.

*

CALL FUNCTION 'READ_TEXT'

EXPORTING

  • CLIENT = SY-MANDT

ID = 'A002'

LANGUAGE = lan

NAME = l_guid

OBJECT = 'CRM_ORDERH'

  • ARCHIVE_HANDLE = 0

  • LOCAL_CAT = ' '

  • IMPORTING

  • HEADER =

TABLES

LINES = i_crmtext.

  • EXCEPTIONS

  • ID = 1

  • LANGUAGE = 2

  • NAME = 3

  • NOT_FOUND = 4

  • OBJECT = 5

  • REFERENCE_CHECK = 6

  • WRONG_ACCESS_TO_ARCHIVE = 7

  • OTHERS = 8

e_t_data-guid = l_guid.

loop at i_crmtext into st_crmtext.

move lan to e_t_data-langu.

move st_crmtext-tdline to e_t_data-description.

append e_t_data.

endif.

endloop.

clear: st_guid,l_guid.

refresh: i_crmtext.

endloop.

S_COUNTER_DATAPAKID = S_COUNTER_DATAPAKID + 1.

endif.

ENDFUNCTION.

please Gurus as I donot know ABAP i appreciate if anyone would write a FM based on requirement and send me that will be really great this is my request. I gurantee of award points for good answers.

Regards

Kishore

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi,

Uncommenting one statement in the block broke the extraction logic. You need to uncomment at least all block.

Look at the link provided by Nagesh and compare codes.

Best regards,

Eugene

Former Member
0 Kudos

Kishore,

i want you to look into this thread. in this thread i gave program for text extracting from CRM system using read_text.

please get bck to me if you have any problems. give me ur mail id.

regards,

Nagesh Ganisetti.

Former Member
0 Kudos

Hi Eugene/Siggi,

Would you please help me in this issue its really very urgent.I followed Eugene but it didnot helped out i even checked the forum link you sent to me it is really very interesting link i think my issue is almost same. I appreciate it in advance. I gurantee of award points

Thanks a lot

Regards

Kishore.

Former Member
0 Kudos

Hi,

The statement <b>RAISE NO_MORE_DATA</b> should be active (uncommented) in your code. Otherwise, the infinte loop occurs.

See also, the Siggi's blog:

/people/siegfried.szameitat/blog/2005/09/29/generic-extraction-via-function-module

BTW, was it your thread here:

?

Best regards,

Eugene