cancel
Showing results for 
Search instead for 
Did you mean: 

Routine in transformation

Former Member
0 Kudos

Hallo experts,

i created an infoobject (ZCO_CMDT) like 0comp_code, but with an file uplaod, so that we can create textes in an excel, uplaod them into ZCO_CMDT. After this we load that 'custom-text' from ZCO_CMDT via a routine into 0comp_code. So we have in 0Comp_code the ERP text and the custom text. This works really fine.

But my problem ist, that i want to use the same text from ZCO_CMDT via routine in 0customer, when the customer ID is smaller than 10.000, but it doesn't work.

Please have a look on that routine:

$$ begin of 2nd part global - insert your code only below this line *

... "insert your code here

$$ end of 2nd part global - insert your code only before this line *

----


  • CLASS routine IMPLEMENTATION

----


*

----


CLASS lcl_transform IMPLEMENTATION.

METHOD compute_0txtmd.

  • IMPORTING

  • request type rsrequest

  • datapackid type rsdatapid

  • SOURCE_FIELDS-KUNNR TYPE C LENGTH 000010

  • SOURCE_FIELDS-TXTMD TYPE C LENGTH 000035

  • EXPORTING

  • RESULT type tys_TG_1-TXTMD

DATA:

monitor_rec TYPE rsmonitor.

$$ begin of routine - insert your code only below this line -

... "insert your code here

*-- fill table "MONITOR" with values of structure "MONITOR_REC"

*- to make monitor entries

... "to cancel the update process

  • raise exception type CX_RSROUT_ABORT.

... "to skip a record

  • raise exception type CX_RSROUT_SKIP_RECORD.

... "to clear target fields

  • raise exception type CX_RSROUT_SKIP_VAL.

FIELD-SYMBOLS: <l_ref1> TYPE ANY.

DATA: lt_text TYPE STANDARD TABLE OF /bic/tzco_cmdt.

DATA: ls_text LIKE LINE OF lt_text.

DATA: /bic/zco_cmdt(10) TYPE n.

SELECT * FROM /bic/tzco_cmdt INTO ls_text WHERE /bic/zco_cmdt =

source_fields-kunnr.

ENDSELECT.

IF ( source_fields-kunnr LT 10000 ) .

ASSIGN ls_text-txtmd TO <l_ref1> .

ELSE.

ASSIGN source_fields-txtmd TO <l_ref1> .

ENDIF.

result = <l_ref1>.

$$ end of routine - insert your code only before this line -

ENDMETHOD. "compute_0TXTMD

The problem is that only the text is filled when the custommer ID is bigger than 10.000.

I'm not sure but I thin the problem that ZCO_CMDT has the type CHAR with a lenght of 4 und 0Customer is the same type, but a lenght of 10.

Can anybody help me crate the routine.

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

start routine:

declaration:

DATA: IT_TEXT TYPE STANDARD TABLE OF /bic/tzco_cmdt.

DATA: WA_TEXT LIKE LINE OF IT_TEXT.

code:

SELECT * FROM /BIC/TZCO_CMDT INTO TABLE IT_TEXT.

field routine in transformation:

DATA: CUST(10) TYPE N,

nkunnr TYPE ZCO_CMDT.

CUST = SOURCE_FIELDS-KUNNR.

IF CUST < 10000.

nkunnr = SOURCE_FIELDS-KUNNR+6.

READ TABLE IT_TEXT WITH KEY /BIC/ZCO_CMDT =

nkunnr INTO WA_TEXT.

MOVE WA_TEXT-txtmd TO RESULT.

ELSE.

MOVE source_fields-txtmd TO RESULT.

ENDIF.

this will work.

Former Member
0 Kudos

i am sorry i have made mistake in the name of work area.

please check below...

according to my understanding zco_cmdt will hold data < 10000 only.

it means that if the customer number which you are dealing woth is present in zco_cmdt then you want to populate the text from its master... right???

if it is like that then you can check with sy-subrc value.

try with the following code if my understanding is correct:

$$ begin of 2nd part global - insert your code only below this line *

... "insert your code here

$$ end of 2nd part global - insert your code only before this line *

-


  • CLASS routine IMPLEMENTATION

-


*

-


CLASS lcl_transform IMPLEMENTATION.

METHOD compute_0txtmd.

  • IMPORTING

  • request type rsrequest

  • datapackid type rsdatapid

  • SOURCE_FIELDS-KUNNR TYPE C LENGTH 000010

  • SOURCE_FIELDS-TXTMD TYPE C LENGTH 000035

  • EXPORTING

  • RESULT type tys_TG_1-TXTMD

DATA:

monitor_rec TYPE rsmonitor.

$$ begin of routine - insert your code only below this line -

... "insert your code here

*-- fill table "MONITOR" with values of structure "MONITOR_REC"

*- to make monitor entries

... "to cancel the update process

  • raise exception type CX_RSROUT_ABORT.

... "to skip a record

  • raise exception type CX_RSROUT_SKIP_RECORD.

... "to clear target fields

  • raise exception type CX_RSROUT_SKIP_VAL.

DATA: IT_TEXT TYPE STANDARD TABLE OF /bic/tzco_cmdt.

DATA: WA_TEXT LIKE LINE OF IT_TEXT.

SELECT * FROM /BIC/TZCO_CMDT INTO TABLE IT_TEXT.

READ TABLE IT_TEXT WITH KEY /BIC/ZCO_CMDT =

SOURCE_FIELDS-kunnr INTO WA_TEXT.

if sy-subrc = 0.

MOVE WA_TEXT-txtmd TO RESULT.

ELSE.

MOVE source_fields-txtmd TO RESULT.

ENDIF.

$$ end of routine - insert your code only before this line -

ENDMETHOD. "compute_0TXTMD

It will be good if you put:

DATA: IT_TEXT TYPE STANDARD TABLE OF /bic/tzco_cmdt.

DATA: WA_TEXT LIKE LINE OF IT_TEXT.

SELECT * FROM /BIC/TZCO_CMDT INTO TABLE IT_TEXT.

in the start routine as this routine will be called for each record and you are repeating to fill internal table.

so put that code in start routine.(put declaration in global declaration part of start routine and select query in the method of start routine).

i think it must work. we have used similar approach for 1 of he report.

Former Member
0 Kudos

@ Dipti Gandhi: You understand everythink right.

Now I tried both ideas, it was the same result. I only get the ERP text independent of the customer ID.

In my routine I (look above) I got only the ERP Text for all cusomer ID > 9.999, but no Text for all customer < 10.000. So I think there is realy a problem, that i didn't find the coding for compare the ZCO_CMDT (Length 4) and 0Customer (length 10).

Further Ideas.

Former Member
0 Kudos

then first use the IF statement and then use select inside the if statement and use only the last four characters of your customer number in the where part of your select statement.



IF ( source_fields-kunnr LT 10000 ) .
  SELECT txtmd FROM /bic/tzco_cmdt INTO <l_ref1> WHERE /bic/zco_cmdt =
           source_fields-kunnr+6(4).
ELSE.
ASSIGN source_fields-txtmd TO <l_ref1> .
ENDIF.
 
result = <l_ref1>.

--- Thanks..

Former Member
0 Kudos

try to put an extra variable to convert that 0customer like:

DATA: CUST TYPE /BIC/ZCO_CMDT.

CUST = SOURCE-FIELDS-KUNNR + 6.

Then in READ stmt use CUST instead of SOURCE-FIELDS-KUNNR.

i think it will help if problem is because of length.

Former Member
0 Kudos

according to my understanding zco_cmdt will hold data < 10000 only.

it means that if the customer number which you are dealing woth is present in zco_cmdt then you want to populate the text from its master... right???

if it is like that then you can check with sy-subrc value.

try with the following code if my understanding is correct:

$$ begin of 2nd part global - insert your code only below this line *

... "insert your code here

$$ end of 2nd part global - insert your code only before this line *

-


  • CLASS routine IMPLEMENTATION

-


*

-


CLASS lcl_transform IMPLEMENTATION.

METHOD compute_0txtmd.

  • IMPORTING

  • request type rsrequest

  • datapackid type rsdatapid

  • SOURCE_FIELDS-KUNNR TYPE C LENGTH 000010

  • SOURCE_FIELDS-TXTMD TYPE C LENGTH 000035

  • EXPORTING

  • RESULT type tys_TG_1-TXTMD

DATA:

monitor_rec TYPE rsmonitor.

$$ begin of routine - insert your code only below this line -

... "insert your code here

*-- fill table "MONITOR" with values of structure "MONITOR_REC"

*- to make monitor entries

... "to cancel the update process

  • raise exception type CX_RSROUT_ABORT.

... "to skip a record

  • raise exception type CX_RSROUT_SKIP_RECORD.

... "to clear target fields

  • raise exception type CX_RSROUT_SKIP_VAL.

DATA: IT_TEXT TYPE STANDARD TABLE OF /bic/tzco_cmdt.

DATA: WA_TEXT LIKE LINE OF IT_TEXT.

SELECT * FROM /BIC/TZCO_CMDT INTO TABLE IT_TEXT.

READ TABLE IT_TEXT WITH KEY /BIC/ZCO_CMDT =

SOURCE_FIELDS-kunnr INTO ITAB_WA.

if sy-subrc = 0.

MOVE IT_TEXT-txtmd TO RESULT.

ELSE.

MOVE source_fields-txtmd TO RESULT.

ENDIF.

$$ end of routine - insert your code only before this line -

ENDMETHOD. "compute_0TXTMD

It will be good if you put:

DATA: IT_TEXT TYPE STANDARD TABLE OF /bic/tzco_cmdt.

DATA: WA_TEXT LIKE LINE OF IT_TEXT.

SELECT * FROM /BIC/TZCO_CMDT INTO TABLE IT_TEXT.

in the start routine as this routine will be called for each record and you are repeating to fill internal table.

so put that code in start routine.(put declaration in global declaration part of start routine and select query in the method of start routine).

i think it must work. we have used similar approach for 1 of he report.

Former Member
0 Kudos

Hi Arthur,

Can you try

IF ( source_fields-kunnr LT '10000' )

Customer number is a CHAR so need the ' '.

Former Member
0 Kudos

@Parth Kulkarni : I tried it, but it didn't solve the problem. I think it is not the if-term. I try to fill the middle text with this routine and if the customer id is bigger than 9.999 than i have the right txt, but if the ID is smaller than 10.000 there is nothing in the middle text of this data set.

@ rookie-sapbi: I'm sure that this would work, but we do not want to customize two Z-infoobkects via fileupload. I'm sure there is a way to use ZCO_CMDT.

Any further ideas?

Former Member
0 Kudos

then don't check for customer number less than 10000

instead try this


SELECT * FROM /bic/tzco_cmdt INTO table lt_text WHERE /bic/zco_cmdt =
source_fields-kunnr.

read table lt_text into ls_text with key /bic/zco_cmdt =
source_fields-kunnr.

IF sy-subrc eq 0  .
ASSIGN ls_text-txtmd TO <l_ref1> .
ELSE.
ASSIGN source_fields-txtmd TO <l_ref1> .
ENDIF.

result = <l_ref1>.

--- Thanks...

Former Member
0 Kudos

Hi Arthur,

if the customer id is bigger than 9.999 than i have the right txt

This is because Customers >9999 are in the ELSE clause. I feel the problem is in IF clause. Did you debug?

Former Member
0 Kudos

Hi @ all,

i now got the solution:

FIELD-SYMBOLS: <l_ref1> TYPE ANY.

DATA: lt_text TYPE STANDARD TABLE OF /bic/tzco_cmdt.

DATA: ls_text LIKE LINE OF lt_text.

SELECT * FROM /bic/tzco_cmdt INTO ls_text WHERE /bic/zco_cmdt =

SOURCE_FIELDS-kunnr+6.

ENDSELECT.

IF ( SOURCE_FIELDS-kunnr LT 10000 ) .

ASSIGN ls_text-txtmd TO <l_ref1> .

ELSE.

ASSIGN SOURCE_FIELDS-txtmd TO <l_ref1> .

ENDIF.

RESULT = <l_ref1>.

You really helped me.

Thanks

Edited by: Arthur Geist on Jun 14, 2011 8:15 AM

Former Member
0 Kudos

you had created ZCO_CMDT similar to 0comp_code to load text from flat files to have ERP text and custom text.

similarly for 0customer, you have to create a Zinfoobject and load text from flat file and then use that Z infoobjects text table in routine to get custom text for 0customer.

--- Thanks...