cancel
Showing results for 
Search instead for 
Did you mean: 

ABAP code in transformation

Former Member
0 Kudos

Hello,

I have a transformation routine as follows:

DATA:l_lifnr1 TYPE /BI0/MBATCH-VENDOR,

l_greybatch TYPE /BI0/MBATCH-BATCH,

oref TYPE REF TO cx_root,

l_num type i,

l_len type i,

l_len1(2) type c.

l_len = strlen( SOURCE_FIELDS-/BIC/ZBAT_SUP ).

l_len1 = ( l_len - 1 ).

try.

concatenate SOURCE_FIELDS-/BIC/ZBAT_SUP+0(l_len1) 'G' into

l_greybatch.

catch CX_SY_CONVERSION_NO_NUMBER INTO oref.

ENDTRY.

=============

this transformation is between a infosource and infoobject. When i run the DTP, it gives an error at the line "concatenate SOURCE_FIELDS-/BIC/ZBAT_SUP+0(l_len1) 'G' into l_greybatch."

This -/BIC/ZBAT_SUP is calculated using a routine in the transformation between the datasource and the infosource. The same DTP is used for both load across both these transformations.

what is wrong? any suggestions?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

What error are you given ?

You can replace with :

move SOURCE_FIELDS-/BIC/ZBAT_SUP(l_len1) to l_greybatch.
move 'G' to l_greybatch+l_len1(1).

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

check if -/BIC/ZBAT_SUP is already filled, may be you need to implement the logic for filling it here too. Additionally you might do it like this:

if l_len1 > 0.

concatenate.....

endif.

regards

Siggi

Former Member
0 Kudos

Hello Siegfried,

Thank you very much.

As you rightly pointed out -/BIC/ZBAT_SUP is not filled.

But i didnt want to fill it in the second transformation(between the infosrc and infoobject) becoz, this is used for populating 2 differnt objects for which there are different rules. I will have to run the logic(for populating -/BIC/ZBAT_SUP) twice in these 2 rules.

Hence i was trying to populate it in the first transformation(between the datasrc and the infosrc) and then use this value in the 2 rules in the second transformation.

Can you give me some other logic to do the same with the necessary ABAP code?

Following is the routine use to populate -/BIC/ZBAT_SUP in the first transformation:

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

DATA: l_charg TYPE /BIC/AZMM_O0100-BATCH.

SELECT SINGLE /BIC/ZBAT_SUP FROM /BIC/AZMM_O0100

into l_charg

WHERE BATCH = SOURCE_FIELDS-CHARG.

RESULT = l_charg .

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

ENDMETHOD. "compute_ZBAT_SUP

====================================================

The second transformation populates 2 different vendor fields in 2 different rules. Both the rules use the follwing 2 routines:

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

DATA:l_lifnr1 TYPE /BI0/MBATCH-VENDOR,

l_greybatch TYPE /BI0/MBATCH-BATCH,

oref TYPE REF TO cx_root,

l_num type i,

l_len type i,

l_len1(2) type c.

l_len = strlen( SOURCE_FIELDS-/BIC/ZBAT_SUP ).

l_len1 = ( l_len - 1 ).

try.

concatenate SOURCE_FIELDS-/BIC/ZBAT_SUP+0(l_len1) 'G' into

l_greybatch.

  • move SOURCE_FIELDS-/BIC/ZBAT_SUP(l_len1) to l_greybatch.

  • move 'G' to l_greybatch+l_len1(1).

catch CX_SY_CONVERSION_NO_NUMBER INTO oref.

ENDTRY.

*Populating Supplying(finished) batch vendor

select single VENDOR from /BI0/MBATCH

into l_lifnr1

where BATCH = l_greybatch.

RESULT = l_lifnr1.

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

ENDMETHOD. "compute_0VENDOR

=====================================================

METHOD compute_ZVENDOR.

  • IMPORTING

  • request type rsrequest

  • datapackid type rsdatapid

  • SOURCE_FIELDS-/BIC/ZBAT_SUP TYPE /BIC/OIZBAT_SUP

  • EXPORTING

  • RESULT type tys_TG_1-/BIC/ZVENDOR

DATA:

MONITOR_REC TYPE rsmonitor.

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

DATA:l_lifnr1 TYPE /BI0/MBATCH-VENDOR.

*Populating Supplying(finished) batch vendor

select single VENDOR from /BI0/MBATCH

into l_lifnr1

where BATCH = SOURCE_FIELDS-/BIC/ZBAT_SUP.

RESULT = l_lifnr1.

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

ENDMETHOD. "compute_ZVENDOR

===================================

thank you....

Former Member
0 Kudos

Hello Experts,

Can you please guide me in this? If I have to avoid the same code getting executed in 2 rules(to populate zbat_sup), what is the solution?

thanks,

Former Member
0 Kudos

Maybe creating an INCLUDE ?