08-26-2007 1:54 PM
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
08-26-2007 2:02 PM
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.
08-26-2007 2:02 PM
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.
08-26-2007 2:14 PM
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
08-26-2007 4:21 PM
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.
08-27-2007 12:01 PM
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