cancel
Showing results for 
Search instead for 
Did you mean: 

BW Transformation help

Former Member
0 Kudos

Hello, i need a little help with abap code in transformation at field routine. I have written a code successfully but now i need to modify a little bit. i am reading another dso and populating the field which works fine. now i want to test three fields coming from source and if those three are blank i want the result to be automatically '0'.  here is what i have done but getting errors:

 

IF SOURCE_FIELDS-ZMARG1

SOURCE_FIELDS- ZMARG2

SOURCE_FIELD-ZMARG3 NE '0'.

READ TABLE IT_ZPUR WITH KEY

MATERIAL = SOURCE_FIELDS-MATNR

INTO WA_ZPUR.

IF SY-SUBRC = 0.

RESULT = WA_PUR-/BIC/ZPUR_ZCHY1.

 

ENDIF.

 

ELSEIF.

RESULT = '0'.

I keep getting "Statement Source_Fields-ZMARG2 not defined".

Please help.

Thanks.

Accepted Solutions (1)

Accepted Solutions (1)

sander_vanwilligen
Active Contributor
0 Kudos

Hi Venkat,

In my opinion the coding should look as follows:

IF NOT SOURCE_FIELDS-ZMARG1 IS INITIAL AND

   NOT SOURCE_FIELDS-ZMARG2 IS INITIAL AND

   NOT SOURCE_FIELDs-ZMARG3 IS INITIAL.

  READ TABLE IT_ZPUR WITH KEY MATERIAL = SOURCE_FIELDS-MATNR

             INTO WA_ZPUR.

  IF SY-SUBRC = 0.

    RESULT = WA_PUR-/BIC/ZPUR_ZCHY1.

  ENDIF.

ELSEIF.

  RESULT = '0'.

ENDIF.

Best regards,

Sander

Former Member
0 Kudos

Sander, thanks but i got this error now:

E:IF, ELSEIF, WHILE, and CHECK must be followed by a logical expression.

former_member229708
Active Participant
0 Kudos

Hi Venkat,

Can you share your entire code for better analysis.

Thanks & Regards,

Vipin

anshu_lilhori
Active Contributor
0 Kudos

Hi,

Whatever Sander van Willigen suggested seems to be correct.The only correction you need to do in the code given is remove the


.

after ELSEIF

This should give you no syntax error.

Please check the same.

Regards,

AL

sander_vanwilligen
Active Contributor
0 Kudos

Hi Venkat,

Small modification in the last part of the coding:

...

ELSE.   "<<< replace elseif by else

  RESULT = '0'.

ENDIF.

If you use ELSEIF a logical expression should follow, this is what the error message is about.

Best regards,

Sander

Answers (1)

Answers (1)

sakthi_ss
Active Participant
0 Kudos

Hi Venkat,

Check this code;

IF ( SOURCE_FIELDS-ZMARG1 ne 0 AND SOURCE_FIELDS-ZMARG2 ne 0 AND SOURCE_FIELDs-ZMARG3 ne 0 ).

  READ TABLE IT_ZPUR WITH KEY MATERIAL = SOURCE_FIELDS-MATNR

             INTO WA_ZPUR.

  IF SY-SUBRC = 0.

    RESULT = WA_PUR-/BIC/ZPUR_ZCHY1.

  ENDIF.

ELSE.

  RESULT = '0'.

ENDIF.

Best regards,

Sakthi