2010 Feb 01 10:16 AM
Hi all,
Iam writing a select query to fetch the description(MAKTX of MAKT) from the material number (MATNR of MARA). So in the table control , I need to display the description.
This is the Scenario : in Table Control, iam having the data for maktx. The matnr field is editable so that the end user can enter material number and get the description from material master (MARA).
if table control already holds the description, If I enter matnr and press enter key, the maktx field should be populated and here if already existed maktx is same as mara-maktx for given matnr, No need to change otherwise, the old description should be overwritten by the new description.
this is my code :
xmatdesc -
internal table
xekpo3 -
internal table for table control.
WHEN 'ENT'.
SELECT a~matnr
b~maktx
INTO CORRESPONDING FIELDS OF TABLE xmatdesc
FROM mara AS a INNER JOIN makt AS b
ON a~matnr = b~matnr
WHERE a~matnr = xekpo3-matnr AND
b~spras = 'EN'.
IF NOT xekpo3-maktx = xmatdesc-maktx. "checking existed maktx with mara-maktx for given matnr.
CLEAR xekpo3-maktx.
MOVE-CORRESPONDING xmatdesc TO xekpo3.
APPEND xekpo3.
ELSE.
EXIT.
ENDIF.
but iam not getting the maktx value in my table control field. Please provide your views and tell me where it is going wrong.
thanking you,
regards
Murali Krishna T
Hi all,
Iam writing a select query to fetch the description(MAKTX of MAKT) from the material number (MATNR of MARA). So in the table control , I need to display the description.
This is the Scenario : in Table Control, iam having the data for maktx. The matnr field is editable so that the end user can enter material number and get the description from material master (MARA).
if table control already holds the description, If I enter matnr and press enter key, the maktx field should be populated and here if already existed maktx is same as mara-maktx for given matnr, No need to change otherwise, the old description should be overwritten by the new description.
this is my code :
xmatdesc -
internal table
xekpo3 -
internal table for table control.
WHEN 'ENT'.
SELECT a~matnr
b~maktx
INTO CORRESPONDING FIELDS OF TABLE xmatdesc
FROM mara AS a INNER JOIN makt AS b
ON a~matnr = b~matnr
WHERE a~matnr = xekpo3-matnr AND
b~spras = 'EN'.
IF NOT xekpo3-maktx = xmatdesc-maktx. "checking existed maktx with mara-maktx for given matnr.
CLEAR xekpo3-maktx.
MOVE-CORRESPONDING xmatdesc TO xekpo3.
APPEND xekpo3.
ELSE.
EXIT.
ENDIF.
but iam not getting the maktx value in my table control field. Please provide your views and tell me where it is going wrong.
thanking you,
regards
Murali Krishna T
2010 Feb 01 10:30 AM
You are moving entries into internal table "CORRESPONDING FIELDS OF TABLE xmatdesc" and comparing with the structure "xekpo3-maktx = xmatdesc-maktx"
Either you remove mapping into internal table Or compare it inside loop - endloop.
Hope you got my point..
2010 Feb 01 10:51 AM
2010 Feb 01 1:11 PM
Hi Murali,
You can do a very simple thing,
Here it is,
In the PAI write this code,
CHAIN.
FIELD MATNR,
FIELD MAKTX. MODULE get_description."Double click on the Module get_description and write the code in it.
ENDCHAIN.
MODULE get_description.
SELECT single b~maktx
into xmatdesc
FROM mara AS a INNER JOIN makt AS b
ON amatnr = bmatnr
WHERE a~matnr = MATNR AND "MATNR - Field Content{color]
b~spras = 'EN'.
IF sy-subrc = 0.
maktx = xmatdesc.
ENDIF.
ENDMODULE.
So the above code will run for all the rows in the table control and update the material description if it is the same then it will overrite.
Hope it helps you,
Regards,
Abhijit G. Borkar
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |