Application Development 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: 

Code - URGENT

Former Member
0 Kudos

Hi All,

At the moment in a query, i am viewing all info related to materials. The issue is, the material description is maintained in 6 different languages, but for few materials, only 3 or 4 are maintained. So when user queries, keeping the language as EN, he wont be able to see a few records. So i want to put a code in the query, where it checks if language is maintained in EN first, if it is there then output the record, if not then check if FR is maintained & so on, so that the user can view the material details atleast in one language. So can anyone help me with this code? Hope my question is clear. Await inputs

Vivek

1 ACCEPTED SOLUTION

GuyF
Active Participant
0 Kudos

You could select all the entries, and then use READ TABLE with the language you want.

DATA: lt_makt TYPE STANDARD TABLE OF makt,

wa_makt TYPE makt.

CHECK itab[] IS NOT INITIAL. " This is the name of your main table

SELECT matnr maktx

FROM makt

INTO CORRESPONDING FIELDS OF TABLE

FOR ALL ENTRIES IN itab

WHERE matnr = itab-matnr.

LOOP AT itab INTO wa_itab.

READ TABLE lt_makt INTO wa_makt WITH KEY matnr = wa_itab-matnr spras = 'E'.

IF sy-subrc = 0.

wa_itab-maktx = wa_makt-maktx.

ELSE.

READ TABLE lt_makt INTO wa_makt WITH KEY matnr = wa_itab-matnr spras = 'F'.

IF sy-subrc = 0.

wa_itab-maktx = wa_makt-maktx.

ENDIF.

ENDIF.

ENDLOOP.

You can copy the code for all the relevant languages that you want.

4 REPLIES 4

GuyF
Active Participant
0 Kudos

You could select all the entries, and then use READ TABLE with the language you want.

DATA: lt_makt TYPE STANDARD TABLE OF makt,

wa_makt TYPE makt.

CHECK itab[] IS NOT INITIAL. " This is the name of your main table

SELECT matnr maktx

FROM makt

INTO CORRESPONDING FIELDS OF TABLE

FOR ALL ENTRIES IN itab

WHERE matnr = itab-matnr.

LOOP AT itab INTO wa_itab.

READ TABLE lt_makt INTO wa_makt WITH KEY matnr = wa_itab-matnr spras = 'E'.

IF sy-subrc = 0.

wa_itab-maktx = wa_makt-maktx.

ELSE.

READ TABLE lt_makt INTO wa_makt WITH KEY matnr = wa_itab-matnr spras = 'F'.

IF sy-subrc = 0.

wa_itab-maktx = wa_makt-maktx.

ENDIF.

ENDIF.

ENDLOOP.

You can copy the code for all the relevant languages that you want.

Former Member
0 Kudos

Hi Guy,

Thanks for the inputs, so if i have understood your inputs correctly, i will have to paste the entire thing starting from DATA: till the end in my SQ01 query & for the other 4 languages, i will have to enter them in

READ TABLE lt_makt INTO wa_makt WITH KEY matnr = wa_itab-matnr spras = 'E'.

IF sy-subrc = 0.

wa_itab-maktx = wa_makt-maktx.

Where i replace E with the respective language & end the loop with ENDIF.

Hope i have understood it clearly.

Vivek

Former Member
0 Kudos

select maktx from makt where matnr = p_matnr

and ( spras eq 'E' or spras eq 'D').

This will try to see for english then for D if english is not found.

Former Member
0 Kudos

Msg for Mr. Guy,

When i entered the code mentioned by you in 'Recording Processing' of SQ01, i get the following error when i tried to generate the infoset

Global syntax check

GET / GET LATE code / Code for Record Processing

Error in code for record processing

Incorrect logical expression: Comparison / SELECT-OPTION can only be followed by "AND", "OR" or ")"

Msg for Mr. Mahesh,

When i entered the code mentioned by you in 'Recording Processing' of SQ01, i get the following error when i tried to generate the infoset

Global syntax check

GET / GET LATE code / Code for Record Processing

Error in code for record processing

Field list without INTO clause is not allowed. itab "OR" INTO (f1....fn)" is not allowed

Kindly let me know what should i do?

Vivek