‎2006 Jul 09 6:15 AM
Hi Experts,
I am new to ABAP,My requirement is to extract long text(160 char) from CRM to BW for that i used standard FM RSAX_BIW_GET_DATA_SIMPLE in that I have called another FM Read_text which will pull the required text based on parameters which i passed from table CRMD_ORDERADM_H and now my problem in that is when I append GUID,Langu and Long text to E_T_DATA, which is my structure through which i replicate that data to BW, as GUID is primary key it must not repeat but it is. When i loop through number of lines of text and append the guid langu and text to E_T_DATA with text, langu and guid is also repeating. This is my FM:
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 ZCRM_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.
***
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: xempl like ZCRM_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 'ZCRM_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 'ZCRM_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: l_guid type THEAD-TDNAME.
*data: I_TDNAME type THEAD-TDNAME.
data: st_guid type xsreph.
*data: I_TDTITLE type THEAD-TDTITLE.
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.
clear: st_crmtext.
endloop.
clear: st_guid, l_guid.
refresh: i_crmtext.
endloop.
S_COUNTER_DATAPAKID = S_COUNTER_DATAPAKID + 1.
endif.
ENDFUNCTION.
Would anyone please suggest me some solution for this. I appreciate it in advance. I gurantee of points for good solutions.
Thanks a lot
Regards
Nagamani.
‎2006 Jul 09 6:53 AM
Hi,
Before passing GUID to READ_TEXT, delete the duplicate records as follows . This will populate the structre with unique GUID's. The structure can later on be extracted in BW.
as we are doing this only once can use the select statement.
data: l_guid type THEAD-TDNAME.
*data: I_TDNAME type THEAD-TDNAME.
data: st_guid type xsreph.
*data: I_TDTITLE type THEAD-TDTITLE.
data: st_crmtext type TLINE.
data: lan type THEAD-TDSPRAS.
lan = 'E'.
************************************************
SORT I_GUID BY GUID.
DELETE ADJACENT DUPLICATES FROM I_GUID COMPARING GUID.
**************************************************
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.
move lan to e_t_data-langu.
loop at i_crmtext into st_crmtext.
move st_crmtext-tdline to e_t_data-description.
append e_t_data.
clear: st_crmtext.
endloop.
clear: st_guid, l_guid.
refresh: i_crmtext.
endloop.
S_COUNTER_DATAPAKID = S_COUNTER_DATAPAKID + 1.
endif.
Best regards,
Prashant
‎2006 Jul 09 7:12 AM
Hi
U can try to use SELECT DISTINCT statament to load the GUID:
select distinct GUID
from (t_tab)
into table i_guid where PROCESS_TYPE = 'ZACI' and ( OBJECT_ID < '0000000042').
Max
‎2006 Jul 09 8:47 PM
Hi Prashanth/Max,
I appreciate quick response but I think i didnot explained my problem to you properly.Actually GUID is repeating in 2nd loop statement when I append GUID,Langu and descrip to e_T_DATA but my requirement is that if we think that there are 5lines of text loop rotates 5times but guid must append e_t_data only once rather than 5times. the code is:
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.*GUID is appending 5times if text has *5lines but it must come only once
clear: st_crmtext.
endloop.
clear: st_guid, l_guid.
refresh: i_crmtext.
endloop.
Would you please suggest me some solution.
Thanks a lot
Regards
Venkat.