09-07-2020 10:33 AM
I got stucked in a very simple program: -
-----------------------------------------------------------
REPORT ZAKB_SUBROUTINE.
DATA : V_MATNR TYPE MATNR,
V_SPRAS TYPE SPRAS,
V_MAKTX TYPE MAKTX,
it_makt type STANDARD TABLE OF makt,
wa_makt type makt.
*PARAMETERS P_MATNR TYPE MATNR.
*AT SELECTION-SCREEN.
*INITIALIZATION.
V_MATNR = '500000072'.
v_spras = 'E'.
select * from makt INTO TABLE it_makt where matnr eq V_MATNR.
*PERFORM GET_maktx in PROGRAM ZAKB_SUBCALL1 USING V_MATNR CHANGING it_makt.
LOOP AT it_makt into wa_makt.
write : / wa_makt-matnr, wa_makt-spras,wa_makt-maktx.
ENDLOOP.
---------------------------------
09-07-2020 10:45 AM
Hello akb1087
Use the CONVERSION_EXIT_MATN1_INPUT function on V_MATNR variable before the SELECT statement. Your material number needs some zeros in front, probably. That's why you're not getting any results from MAKT table.
Also, you don't have your V_SPRAS in the SELECT statement.
Kind regards,09-07-2020 10:34 AM
Hi and welcome to the SAP Community!
Thank you for visiting SAP Community to get answers to your questions. Since you're asking a question here for the first time, I recommend that you familiarize yourself with https://community.sap.com/resources/questions-and-answers (if you haven't already), as it provides tips for preparing questions that draw responses from our members. For example, you can outline what steps you took to find answers (and why they weren't helpful) and share screenshots of what you've seen/done. The more details you provide, the more likely it is that members will be able to assist you.
Should you wish, you can revise your question by selecting Actions, then Edit (although once someone answers your question, you'll lose the ability to edit the question -- but if that happens, you can leave more details in a comment).
Finally, if you're hoping to connect with readers, please consider adding a picture to your profile. Here's how you do it: https://www.youtube.com/watch?v=F5JdUbyjfMA&list=PLpQebylHrdh5s3gwy-h6RtymfDpoz3vDS. By personalizing your profile with a photo of you, you encourage readers to respond.
Cheers,
Julia SAP Community Moderator
09-07-2020 10:41 AM
Please use the COMMENT button for comments, questions, adding details, replying to OP comment, etc., ANSWER is only to propose a solution, dixit SAP text at the right of the answer area.
09-07-2020 10:45 AM
Hello akb1087
Use the CONVERSION_EXIT_MATN1_INPUT function on V_MATNR variable before the SELECT statement. Your material number needs some zeros in front, probably. That's why you're not getting any results from MAKT table.
Also, you don't have your V_SPRAS in the SELECT statement.
Kind regards,09-07-2020 11:12 PM
09-07-2020 11:57 AM
Hello akb1087,
When you query inputs from table using values you have to ensure the values are converted using conversion exits because entries stored in the table may have conversion exits assigned and they would have stored accordingly (With Leading Zeros).
In your Case you have done the mistake of not formatting the input, below code should be working fine for you.
DATA : v_matnr TYPE matnr,
v_spras TYPE spras,
v_maktx TYPE maktx,
it_makt TYPE STANDARD TABLE OF makt,
wa_makt TYPE makt.
*INITIALIZATION.
v_matnr = '500000072'.
v_spras = 'E'.
v_matnr = |{ v_matnr ALPHA = IN }|. ---> New Syntax (Use either this or old syntax)
CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT' --> Old Syntax (Use either this or new syntax)
EXPORTING
input = v_matnr
IMPORTING
output = v_matnr
EXCEPTIONS
length_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
SELECT * FROM makt INTO TABLE it_makt WHERE matnr EQ v_matnr AND
spras EQ v_spras.
LOOP AT it_makt INTO wa_makt.
WRITE : / wa_makt-matnr, wa_makt-spras,wa_makt-maktx.
ENDLOOP.
To find out whether we need to apply conversion exits for a field, reach out to the domain of the table and check the field ROUTINE.
Regards!
09-07-2020 11:12 PM
09-07-2020 11:12 PM
When executing this program by direct assigning value to variable(V_MATNR) it does not give any result. But when executing it by accepting user input by parameter, it gives the exact result.