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

Basic ABAP code

0 Likes
1,466

From the installation number(ANLAGE) go to ETRG where ABVORG equals 01 or 03 then get ADATSOLL

Please help me in writing the code in SAP ABAP. Thanks in advance

5 REPLIES 5
Read only

Former Member
0 Likes
1,359
Thank you for visiting SAP Community to get answers to your questions. Since this is your first question, I recommend that you familiarize yourself with: https://community.sap.com/resources/questions-and-answers, as the overview provides tips for preparing questions that draw responses from our members. Should you wish, you can revise your question by selecting Actions, then Edit. By adding a picture to your profile you encourage readers to respond: https://developers.sap.com/tutorials/community-profile.html
Read only

Sandra_Rossi
Active Contributor
0 Likes
1,359

You should learn ABAP.

SELECT ADATSOLL FROM ETRG where ANLAGE = ... AND ABVORG in ('01','03') into ...

Or do you have a specific question?

Read only

anujawani242683
Active Participant
0 Likes
1,359

Hi,

Please try below code.

PARAMETERS:anlage type anlage.
data:it_etrg type table of etrg,
wa_etrg type etrg.
SELECT
adatsoll
from
etrg
into CORRESPONDING FIELDS OF table it_etrg
where abrvorgu in ('01','03')
and anlage = anlage.
loop at it_etrg into wa_etrg.
write:/ wa_etrg-adatsoll.
ENDLOOP.

Regards,

Anuja Kawadiwale

Read only

1,359

anujawani2426 when you create an internal table type table of an ABAP dictionary table, you use a big quantity of memory, you have a lot of unused fields available in this internal table. Second point, there is new way of writing SELECT statement with @ before variables.

PARAMETERS anlage type anlage.
SELECT adatsoll
FROM etrg
INTO TABLE @DATA(it_etrg)
WHERE abrvorgu IN ('01','03') "<-- should be constants with human readable name
AND anlage EQ @anlage.
LOOP AT it_etrg INTO DATA(wa_etrg).
WRITE: / wa_etrg-adatsoll.
ENDLOOP.
Read only

0 Likes
1,359

Hi Frederic,

Yes i know. I just shared sample code to run and check the result. And as per requirement we can create a structure with limited fields and can declare internal table of type structure also we can use inline declaration. But as of know dont know exact requirement thats why i shared this sample code. We can do so many things for optimization when we have exact requirement.

Regards,

Anuja Kawadiwale