Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Not getting proper output

pooja08
Explorer
0 Likes
2,656

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.

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.

11 REPLIES 11
Read only

Sandra_Rossi
Active Contributor
0 Likes
2,553
  • "not getting proper output"

What do you get?

What do you expect?

Read only

pooja08
Explorer
0 Likes
2,553

Output for equnr is something like 2**********.

but receiving only 20.

Read only

Sandra_Rossi
Active Contributor
2,553

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.

Read only

pooja08
Explorer
0 Likes
2,553
TABLES : AFIH,AUFK.
TYPES : BEGIN OF ST,
AUFNR TYPE Afih-aufnr,
EQUNR TYPE AFIH-equnr,

END OF ST.

I did the declaration part

Read only

Abhishek_10
Participant
0 Likes
2,553

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.

Read only

0 Likes
2,553

No, it won't fix the issue, because "SELECT equnr" would then transfer to WA-MANDT, truncated at 3 characters.

Read only

2,553

Ok then into corresponding fields of table it can be used.

Read only

Sandra_Rossi
Active Contributor
2,553

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
Read only

Sandra_Rossi
Active Contributor
2,553

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!

Read only

pooja08
Explorer
2,553

Thank you sandra , Got output

Read only

Sandra_Rossi
Active Contributor
0 Likes
2,553

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