Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Abap code for combining two fields in transformation rule

Former Member
0 Likes
724

Hi,

I want to write a routine in a transformation rule that combines two fields from one virtual cube into one field in my destination cube. The combination should work according to this pseudo code:

If (current year)

then FieldA should be used

else

then FieldB should be used

Does anybody know how the abap code for this should be?

Thank you in advance,

Best regards,

Mikael Kilåker

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
661

Hi,

I still have not been able to solve the problem, my code looks like:

data: v_year(4) type c.

move sy-datum+4(4) to v_year.

if SOURCE_FIELDS-CALYEAR eq v_year.

  • RESULT = SOURCE_FIELDS-/BIC/VE_SALHIS.

move SOURCE_FIELDS-/BIC/VE_SALHIS to RESULT.

else.

  • RESULT = SOURCE_FIELDS-/BIC/VE_SETS.

move SOURCE_FIELDS-/BIC/VE_SETS to RESULT.

endif.

I have also tried using the rows that are commented, but for some reason the if statement is never true, so only data from SOURCE_FIELDS-/BIC/VE_SETS is transformed into my result variable.

Any idea?

Best regards,

Mikael

Hi,

I still have not been able to solve the problem, my code looks like:

data: v_year(4) type c.

move sy-datum+4(4) to v_year.

if SOURCE_FIELDS-CALYEAR eq v_year.

  • RESULT = SOURCE_FIELDS-/BIC/VE_SALHIS.

move SOURCE_FIELDS-/BIC/VE_SALHIS to RESULT.

else.

  • RESULT = SOURCE_FIELDS-/BIC/VE_SETS.

move SOURCE_FIELDS-/BIC/VE_SETS to RESULT.

endif.

I have also tried using the rows that are commented, but for some reason the if statement is never true, so only data from SOURCE_FIELDS-/BIC/VE_SETS is transformed into my result variable.

Any idea?

Best regards,

Mikael

4 REPLIES 4
Read only

former_member194669
Active Contributor
0 Likes
661

Hi,

may like this way


data : v_year(4) type c.
move sy-datum+4(4) to v_year. " Here v_year will be 2007

If <your variable having year> eq v_year.
   move fieldA to 
else.
   move fieldB to
endif.
 

Read only

Former Member
0 Likes
662

Hi,

I still have not been able to solve the problem, my code looks like:

data: v_year(4) type c.

move sy-datum+4(4) to v_year.

if SOURCE_FIELDS-CALYEAR eq v_year.

  • RESULT = SOURCE_FIELDS-/BIC/VE_SALHIS.

move SOURCE_FIELDS-/BIC/VE_SALHIS to RESULT.

else.

  • RESULT = SOURCE_FIELDS-/BIC/VE_SETS.

move SOURCE_FIELDS-/BIC/VE_SETS to RESULT.

endif.

I have also tried using the rows that are commented, but for some reason the if statement is never true, so only data from SOURCE_FIELDS-/BIC/VE_SETS is transformed into my result variable.

Any idea?

Best regards,

Mikael

Read only

0 Likes
661

Hi mikael,

1. Dates in backend are usually stored in YYYYMMDD format.

2. Hence, the syntax should be

<b>move sy-datum(4) to v_year.</b>

instead of

move sy-datum+4(4) to v_year.

regards,

amit m.

Read only

former_member194669
Active Contributor
0 Likes
661

Hi,

Please check your sy-datum how it get stored.

The following is way move syntax get worked. Please below mentioned example.

related to how MOVE syntax worked.

MOVE foff1(len1) TO goff2(len2).

Effect

With offset off2 and length len2, field g receives the contents of field f with offset off1 and length len1. The offset and length specifications can also be variable.

Example

DATA: FIELD1(10) VALUE '1234567890',

OFF1 TYPE I VALUE 1,

LEN1 TYPE I VALUE 2,

FIELD2(8) VALUE 'abcdefgh',

OFF2 TYPE I VALUE 3,

LEN2 TYPE I VALUE 4.

MOVE FIELD1OFF1(LEN1) TO FIELD2OFF2(LEN2).

FIELD2 now has the value 'abc23 h'.

aRs