2023 Jul 29 3:10 PM
Hi experts, A simple code wrote, but i am not getting proper output...Please let me know where i did mistake.
DATA : IT TYPE STANDARD TABLE OF ST, WA TYPE st.
PARAMETERS : p_aufnr type aufk-aufnr.
SELECT equnr FROM afih INTO TABLE it WHERE aufnr = p_aufnr.
loop AT IT INTO WA.
write : / wa-equnr,
wa-aufnr.
ENDLOOP.
2023 Jul 29 3:11 PM
What do you get?
What do you expect?
2023 Jul 29 3:19 PM
Output for equnr is something like 2**********.
but receiving only 20.
2023 Jul 29 3:23 PM
because you declare ST with EQUNR with only 2 characters.
It should be
equnr TYPE afih-equnr,
probably you have used another type...
Also be careful to have exactly the same columns and same order both after SELECT and in the type of ST. NB: the names of the components are not important.
2023 Jul 29 3:31 PM
END OF ST.
I did the declaration part
2023 Jul 29 3:34 PM
Can you modify your first line of code from
DATA : IT TYPE STANDARD TABLE OF ST, WA TYPE st.
To
DATA : IT TYPE STANDARD TABLE OF afih, WA TYPE afih.
This will fix your size issue.
2023 Jul 29 3:45 PM
No, it won't fix the issue, because "SELECT equnr" would then transfer to WA-MANDT, truncated at 3 characters.
2023 Jul 29 6:12 PM
2023 Jul 29 3:43 PM
I said: "the same columns and same order"
But you did:
TYPES : BEGIN OF ST,
AUFNR TYPE Afih-aufnr,
EQUNR TYPE AFIH-equnr,
END OF ST.
and SELECT is missing AUFNR:
SELECT equnr
So, do:
SELECT aufnr equnr
2023 Jul 29 3:44 PM
By the way, please edit your question (Actions>Edit), select your code and press the button [CODE], which makes the code appear colored/indented, it'll be easier for people to look at it. Thanks!
2023 Jul 29 5:59 PM
2023 Jul 29 6:47 PM
This is an answer to let visitors know that it's solved. Your buggy code:
TYPES : BEGIN OF ST,
AUFNR TYPE Afih-aufnr,
EQUNR TYPE AFIH-equnr,
END OF ST.
DATA : IT TYPE STANDARD TABLE OF ST,
WA TYPE st.
PARAMETERS : p_aufnr type aufk-aufnr.
SELECT equnr "<========== don't correspond to IT
FROM afih
INTO TABLE it
WHERE aufnr = p_aufnr.
loop AT IT INTO WA.
write : / wa-equnr, wa-aufnr.
ENDLOOP.
Be careful to have exactly the same columns and same order both after SELECT and in the type of ST.
SELECT contains only EQUNR, it's missing AUFNR as you can see in ST (components AUFNR and EQUNR):
SELECT equnr
So, do:
SELECT aufnr equnr