Application Development 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: 

Not getting proper output

pooja08
Explorer
0 Kudos
612

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

Sandra_Rossi
Active Contributor
0 Kudos
509
  • "not getting proper output"

What do you get?

What do you expect?

pooja08
Explorer
0 Kudos
509

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

but receiving only 20.

Sandra_Rossi
Active Contributor
509

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.

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

END OF ST.

I did the declaration part

Abhishek_10
Participant
0 Kudos
509

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.

0 Kudos
509

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

509

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

Sandra_Rossi
Active Contributor
509

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

Sandra_Rossi
Active Contributor
509

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!

pooja08
Explorer
509

Thank you sandra , Got output

Sandra_Rossi
Active Contributor
0 Kudos
509

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