Skip to Content
-5

simple abap program

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.

---------------------------------

Add a comment
10|10000 characters needed characters exceeded

  • 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

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Sep 07 at 09:45 AM

    Hello Anil Kumar

    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,
    Mateusz
    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Sep 07 at 10:57 AM

    Hello Anil Kumar,

    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!

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.