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

Need help to check my code !

Former Member
0 Likes
1,208

I am not ble to fetch all the data .

Where is the problem !

please help me to modify the select statement

REPORT YINTERACTIVEPROGRAM01.

**********************************************************************

*CREATED BY:JYOTIRMOY DEB *

  • *

*DATE OF CREATION : *

  • *

**********************************************************************

*TABLE DECLARATION

********************

TABLES:VBAK, "Sales Document: Header Data

VBKD, "Sales Document: Business Data

VBPA, "Sales Document: Partner

VBAP, "Sales Document: Item Data

ADRC, "Addresses (central address admin.)

T178T, "Conditions: Groups for Materials:text

T188T, "Pricing groups for customers

TVM1,

TVM1T, "Material pricing group 1: Description

TVM2,

TVM2T, "Material Pricing Group 2: Description

TVM3,

TVM3T, "Material Pricing Group 3: Description

TVM4,

TVM4T, "Material Pricing Group 4: Description

TVM5,

TVM5T, "Material Pricing Group 5: Description

SZA1_D0100,

TVLV , "Check table for release orders: Usage ID

TVLVT,

TVKGG, "Customer Condition Groups (Customer Master)

TVKGGT,

TPAR, "Business Partner: Functions

TPART,

TVAUT. "Sales Documents: Order Reasons: Texts

*SELECT OPTIONS

****************

Select-options S_VBELN for vbak-vbeln.

*CREATING INTERNAL TABLES

TYPES:BEGIN OF TY_TAB,

VBELN LIKE VBAK-VBELN,

VKORG LIKE VBAK-VKORG,

ERDAT LIKE VBAK-ERDAT,

AUGRU LIKE VBAK-AUGRU,

BEZEI LIKE TVAUT-BEZEI,

BSTDK LIKE VBKD-BSTDK,

BSTDK_E LIKE VBKD-BSTDK_E,

BSTKD LIKE VBKD-BSTKD,

KDKG2 LIKE VBKD-KDKG2,

KONDA LIKE VBKD-KONDA,

MATNR LIKE VBAP-MATNR,

SPART LIKE VBAP-SPART,

KONDM LIKE VBAP-KONDM,

WAERK LIKE VBAP-WAERK,

NETWR LIKE VBAP-NETWR,

KWMENG LIKE VBAP-KWMENG,

VKAUS LIKE VBAP-VKAUS,

MVGR1 LIKE VBAP-MVGR1,

MVGR2 LIKE VBAP-MVGR2,

MVGR3 LIKE VBAP-MVGR3,

MVGR4 LIKE VBAP-MVGR4,

MVGR5 LIKE VBAP-MVGR5,

KUNNR LIKE VBPA-KUNNR,

POSTCODE1 LIKE ADRC-POST_CODE1,

POBOX LIKE ADRC-PO_BOX,

NAME1 LIKE ADRC-NAME1,

NAME2 LIKE ADRC-NAME2,

CITY1 LIKE ADRC-CITY1,

CITY2 LIKE ADRC-CITY2,

COUNTRY LIKE ADRC-COUNTRY,

STREET LIKE ADRC-STREET,

STRSUPPL1 LIKE ADRC-STR_SUPPL1,

STRSUPPL2 LIKE ADRC-STR_SUPPL2,

STRSUPPL3 LIKE ADRC-STR_SUPPL3,

NRART LIKE TPAR-NRART,

VTEXT1 LIKE TPART-VTEXT,

PARVW LIKE TPART-PARVW,

BEZE_I LIKE TVLVT-BEZEI,

VTEXT LIKE V_T178-VTEXT,

V_TEXT like V_T188-VTEXT,

BEZEI1 LIKE TVM1T-BEZEI,

BEZEI2 LIKE TVM2T-BEZEI,

BEZEI3 LIKE TVM3T-BEZEI,

BEZEI4 LIKE TVM4T-BEZEI,

BEZEI5 LIKE TVM5T-BEZEI,

VTEXT2 LIKE TVKGGT-VTEXT,

SMTP_ADDR LIKE ADR6-SMTP_ADDR,

END OF TY_TAB.

DATA: ITAB TYPE STANDARD TABLE OF TY_TAB WITH HEADER LINE.

*WRITING THE QUERY

SELECT A1~VBELN

A1~VKORG

A1~ERDAT

A1~AUGRU

A2~BSTDK

A2~BSTDK_E

A2~BSTDK

A2~KONDA

A2~KDKG2

A3~MATNR

A3~SPART

A3~KONDM

A3~WAERK

A3~NETWR

A3~KWMENG

A3~VKAUS

A3~MVGR1

A3~MVGR2

A3~MVGR3

A3~MVGR4

A3~MVGR5

A4~POST_CODE1

A4~PO_BOX

A4~NAME1

A4~NAME2

A4~CITY1

A4~CITY2

A4~COUNTRY

A4~STREET

A4~STR_SUPPL1

A4~STR_SUPPL2

A4~STR_SUPPL3

A5~BEZEI

A6~KUNNR

A7~NRART

A8~VTEXT

A9~PARVW

A10~BEZEI

A11~VTEXT

A12~VTEXT

A13~BEZEI

A14~BEZEI

A15~BEZEI

A16~BEZEI

A17~BEZEI

A18~VTEXT

  • A20~SMTP_ADDR

INTO CORRESPONDING FIELDS OF TABLE ITAB

FROM VBAK AS A1

JOIN VBKD AS A2

ON A1VBELN = A2VBELN

JOIN VBAP AS A3

ON A1VBELN = A3VBELN

LEFT OUTER JOIN VBPA AS A6

ON A2VBELN = A6VBELN

AND A2POSNR = A6POSNR

*JOIN ADR6 AS A20

*ON A6ADRNR = A20ADDRNUMBER

JOIN ADRC AS A4

ON A6ADRNR = A4ADDRNUMBER

LEFT OUTER JOIN TVM1T AS A13

ON A3MVGR1 = A13MVGR1

LEFT OUTER JOIN TVM2T AS A14

ON A3MVGR2 = A14MVGR2

LEFT OUTER JOIN TVM3T AS A15

ON A3MVGR3 = A15MVGR3

LEFT OUTER JOIN TVM4T AS A16

ON A3MVGR4 = A16MVGR4

LEFT OUTER JOIN TVM5T AS A17

ON A3MVGR5 = A17MVGR5

JOIN TPAR AS A7

ON A7PARVW = A6PARVW

JOIN TPART AS A8

ON A8PARVW = A6PARVW

LEFT OUTER JOIN T178T AS A11

ON A3KONDM = A11KONDM

AND A11~SPRAS = SY-LANGU

LEFT OUTER JOIN T188T as A12

ON A2KONDA = A12KONDA

AND A12~SPRAS = SY-LANGU

JOIN TPART AS A9

ON A6PARVW = A9PARVW

LEFT OUTER JOIN TVLVT AS A10

ON A1ABRVW = A10ABRVW

AND A10~SPRAS = SY-LANGU

LEFT OUTER JOIN TVAUT AS A5

ON A1AUGRU = A5AUGRU

AND A5~SPRAS = SY-LANGU

LEFT OUTER JOIN TVKGGT AS A18

ON A8SPRAS = A18SPRAS

UP TO 100 ROWS

WHERE A1~VBELN IN S_VBELN.

*PRINTING THE OUTPUT

loop AT ITAB.

WRITE :

/(30) 'Order No :', itab-VBELN,

/(30) 'Sales Org :', itab-VKORG,

/(30) 'Order Date :', itab-ERDAT,

/(30) 'Purchase Order # :', itab-BSTKD,

/(30) 'Purchase Order Date :', itab-BSTDK,

/(30) 'Order Reason code :', itab-AUGRU,

/(30) 'Order Reason description :', itab-BEZEI,

/(30) 'Partner Type :', itab-NRART,

/(30) 'Partner Type description :', itab-VTEXT,

/(30) 'Partner no :', itab-KUNNR,

/(30) 'Partner Name1 :', itab-NAME1,

/(30) 'Partner Name2 :', itab-NAME2,

/(30) 'Partner Address 1 :', itab-STREET,

/(30) 'Partner Address 2 :', itab-STRSUPPL1,

/(30) 'Partner Address 3 :', itab-STRSUPPL2,

/(30) 'Partner Address 4 :', itab-STRSUPPL3,

/(30) 'City :', itab-CITY1,

/(30) 'DISTRICT :', itab-CITY2,

/(30) 'Country :', itab-COUNTRY,

/(30) 'Post Code :', itab-POSTCODE1,

/(30) 'PO BOX :', itab-POBOX,

/(30) 'Partner email :', itab-SMTP_ADDR,

/(30) 'Material no :', itab-MATNR,

/(30) 'Material Division :', itab-SPART,

/(30) 'Product Line and Edition code:', itab-MVGR1,

/(30) 'Product Line and Edition Desc:', itab-BEZEI1,

/(30) 'Product Name code :', itab-MVGR2,

/(30) 'ProductName Desc :', itab-BEZEI2,

/(30) 'Product Version Code :', itab-MVGR3,

/(30) 'Product Version Desc :', itab-BEZEI3,

/(30) 'Product Platform Code :', itab-MVGR4,

/(30) 'Product Platform Desc :', itab-BEZEI4,

/(30) 'Product App Server Code :', itab-MVGR5,

/(30) 'Product App Server Desc :', itab-BEZEI5,

/(30) 'Compiler Code :', itab-KONDM,

/(30) 'Compiler Desc :', itab-VTEXT,

/(30) 'LanguageCode :', itab-KONDA,

/(30) 'LanguageDesc :', itab-V_TEXT,

/(30) 'Runtime Band Code :', itab-VKAUS,

/(30) 'Runtime Band description :', itab-BEZE_I,

/(30) 'Support Start Date :', itab-BSTDK,

/(30) 'Support End Date :', itab-BSTDK_E,

/(30) 'Support Level Code :', itab-KDKG2,

/(30) 'Support Level Desc :', itab-VTEXT2,

/(30) 'Order Quantity :', itab-KWMENG,

/(30) 'Net Price :', itab-NETWR,

/(30) 'Currency :', itab-WAERK.

uline.

ENDLOOP.

if sy-subrc <> 0.

write : / 'No data found'.

endif.

I am not ble to fetch all the data .

Where is the problem !

please help me to modify the select statement

REPORT YINTERACTIVEPROGRAM01.

**********************************************************************

*CREATED BY:JYOTIRMOY DEB *

  • *

*DATE OF CREATION : *

  • *

**********************************************************************

*TABLE DECLARATION

********************

TABLES:VBAK, "Sales Document: Header Data

VBKD, "Sales Document: Business Data

VBPA, "Sales Document: Partner

VBAP, "Sales Document: Item Data

ADRC, "Addresses (central address admin.)

T178T, "Conditions: Groups for Materials:text

T188T, "Pricing groups for customers

TVM1,

TVM1T, "Material pricing group 1: Description

TVM2,

TVM2T, "Material Pricing Group 2: Description

TVM3,

TVM3T, "Material Pricing Group 3: Description

TVM4,

TVM4T, "Material Pricing Group 4: Description

TVM5,

TVM5T, "Material Pricing Group 5: Description

SZA1_D0100,

TVLV , "Check table for release orders: Usage ID

TVLVT,

TVKGG, "Customer Condition Groups (Customer Master)

TVKGGT,

TPAR, "Business Partner: Functions

TPART,

TVAUT. "Sales Documents: Order Reasons: Texts

*SELECT OPTIONS

****************

Select-options S_VBELN for vbak-vbeln.

*CREATING INTERNAL TABLES

TYPES:BEGIN OF TY_TAB,

VBELN LIKE VBAK-VBELN,

VKORG LIKE VBAK-VKORG,

ERDAT LIKE VBAK-ERDAT,

AUGRU LIKE VBAK-AUGRU,

BEZEI LIKE TVAUT-BEZEI,

BSTDK LIKE VBKD-BSTDK,

BSTDK_E LIKE VBKD-BSTDK_E,

BSTKD LIKE VBKD-BSTKD,

KDKG2 LIKE VBKD-KDKG2,

KONDA LIKE VBKD-KONDA,

MATNR LIKE VBAP-MATNR,

SPART LIKE VBAP-SPART,

KONDM LIKE VBAP-KONDM,

WAERK LIKE VBAP-WAERK,

NETWR LIKE VBAP-NETWR,

KWMENG LIKE VBAP-KWMENG,

VKAUS LIKE VBAP-VKAUS,

MVGR1 LIKE VBAP-MVGR1,

MVGR2 LIKE VBAP-MVGR2,

MVGR3 LIKE VBAP-MVGR3,

MVGR4 LIKE VBAP-MVGR4,

MVGR5 LIKE VBAP-MVGR5,

KUNNR LIKE VBPA-KUNNR,

POSTCODE1 LIKE ADRC-POST_CODE1,

POBOX LIKE ADRC-PO_BOX,

NAME1 LIKE ADRC-NAME1,

NAME2 LIKE ADRC-NAME2,

CITY1 LIKE ADRC-CITY1,

CITY2 LIKE ADRC-CITY2,

COUNTRY LIKE ADRC-COUNTRY,

STREET LIKE ADRC-STREET,

STRSUPPL1 LIKE ADRC-STR_SUPPL1,

STRSUPPL2 LIKE ADRC-STR_SUPPL2,

STRSUPPL3 LIKE ADRC-STR_SUPPL3,

NRART LIKE TPAR-NRART,

VTEXT1 LIKE TPART-VTEXT,

PARVW LIKE TPART-PARVW,

BEZE_I LIKE TVLVT-BEZEI,

VTEXT LIKE V_T178-VTEXT,

V_TEXT like V_T188-VTEXT,

BEZEI1 LIKE TVM1T-BEZEI,

BEZEI2 LIKE TVM2T-BEZEI,

BEZEI3 LIKE TVM3T-BEZEI,

BEZEI4 LIKE TVM4T-BEZEI,

BEZEI5 LIKE TVM5T-BEZEI,

VTEXT2 LIKE TVKGGT-VTEXT,

SMTP_ADDR LIKE ADR6-SMTP_ADDR,

END OF TY_TAB.

DATA: ITAB TYPE STANDARD TABLE OF TY_TAB WITH HEADER LINE.

*WRITING THE QUERY

SELECT A1~VBELN

A1~VKORG

A1~ERDAT

A1~AUGRU

A2~BSTDK

A2~BSTDK_E

A2~BSTDK

A2~KONDA

A2~KDKG2

A3~MATNR

A3~SPART

A3~KONDM

A3~WAERK

A3~NETWR

A3~KWMENG

A3~VKAUS

A3~MVGR1

A3~MVGR2

A3~MVGR3

A3~MVGR4

A3~MVGR5

A4~POST_CODE1

A4~PO_BOX

A4~NAME1

A4~NAME2

A4~CITY1

A4~CITY2

A4~COUNTRY

A4~STREET

A4~STR_SUPPL1

A4~STR_SUPPL2

A4~STR_SUPPL3

A5~BEZEI

A6~KUNNR

A7~NRART

A8~VTEXT

A9~PARVW

A10~BEZEI

A11~VTEXT

A12~VTEXT

A13~BEZEI

A14~BEZEI

A15~BEZEI

A16~BEZEI

A17~BEZEI

A18~VTEXT

  • A20~SMTP_ADDR

INTO CORRESPONDING FIELDS OF TABLE ITAB

FROM VBAK AS A1

JOIN VBKD AS A2

ON A1VBELN = A2VBELN

JOIN VBAP AS A3

ON A1VBELN = A3VBELN

LEFT OUTER JOIN VBPA AS A6

ON A2VBELN = A6VBELN

AND A2POSNR = A6POSNR

*JOIN ADR6 AS A20

*ON A6ADRNR = A20ADDRNUMBER

JOIN ADRC AS A4

ON A6ADRNR = A4ADDRNUMBER

LEFT OUTER JOIN TVM1T AS A13

ON A3MVGR1 = A13MVGR1

LEFT OUTER JOIN TVM2T AS A14

ON A3MVGR2 = A14MVGR2

LEFT OUTER JOIN TVM3T AS A15

ON A3MVGR3 = A15MVGR3

LEFT OUTER JOIN TVM4T AS A16

ON A3MVGR4 = A16MVGR4

LEFT OUTER JOIN TVM5T AS A17

ON A3MVGR5 = A17MVGR5

JOIN TPAR AS A7

ON A7PARVW = A6PARVW

JOIN TPART AS A8

ON A8PARVW = A6PARVW

LEFT OUTER JOIN T178T AS A11

ON A3KONDM = A11KONDM

AND A11~SPRAS = SY-LANGU

LEFT OUTER JOIN T188T as A12

ON A2KONDA = A12KONDA

AND A12~SPRAS = SY-LANGU

JOIN TPART AS A9

ON A6PARVW = A9PARVW

LEFT OUTER JOIN TVLVT AS A10

ON A1ABRVW = A10ABRVW

AND A10~SPRAS = SY-LANGU

LEFT OUTER JOIN TVAUT AS A5

ON A1AUGRU = A5AUGRU

AND A5~SPRAS = SY-LANGU

LEFT OUTER JOIN TVKGGT AS A18

ON A8SPRAS = A18SPRAS

UP TO 100 ROWS

WHERE A1~VBELN IN S_VBELN.

*PRINTING THE OUTPUT

loop AT ITAB.

WRITE :

/(30) 'Order No :', itab-VBELN,

/(30) 'Sales Org :', itab-VKORG,

/(30) 'Order Date :', itab-ERDAT,

/(30) 'Purchase Order # :', itab-BSTKD,

/(30) 'Purchase Order Date :', itab-BSTDK,

/(30) 'Order Reason code :', itab-AUGRU,

/(30) 'Order Reason description :', itab-BEZEI,

/(30) 'Partner Type :', itab-NRART,

/(30) 'Partner Type description :', itab-VTEXT,

/(30) 'Partner no :', itab-KUNNR,

/(30) 'Partner Name1 :', itab-NAME1,

/(30) 'Partner Name2 :', itab-NAME2,

/(30) 'Partner Address 1 :', itab-STREET,

/(30) 'Partner Address 2 :', itab-STRSUPPL1,

/(30) 'Partner Address 3 :', itab-STRSUPPL2,

/(30) 'Partner Address 4 :', itab-STRSUPPL3,

/(30) 'City :', itab-CITY1,

/(30) 'DISTRICT :', itab-CITY2,

/(30) 'Country :', itab-COUNTRY,

/(30) 'Post Code :', itab-POSTCODE1,

/(30) 'PO BOX :', itab-POBOX,

/(30) 'Partner email :', itab-SMTP_ADDR,

/(30) 'Material no :', itab-MATNR,

/(30) 'Material Division :', itab-SPART,

/(30) 'Product Line and Edition code:', itab-MVGR1,

/(30) 'Product Line and Edition Desc:', itab-BEZEI1,

/(30) 'Product Name code :', itab-MVGR2,

/(30) 'ProductName Desc :', itab-BEZEI2,

/(30) 'Product Version Code :', itab-MVGR3,

/(30) 'Product Version Desc :', itab-BEZEI3,

/(30) 'Product Platform Code :', itab-MVGR4,

/(30) 'Product Platform Desc :', itab-BEZEI4,

/(30) 'Product App Server Code :', itab-MVGR5,

/(30) 'Product App Server Desc :', itab-BEZEI5,

/(30) 'Compiler Code :', itab-KONDM,

/(30) 'Compiler Desc :', itab-VTEXT,

/(30) 'LanguageCode :', itab-KONDA,

/(30) 'LanguageDesc :', itab-V_TEXT,

/(30) 'Runtime Band Code :', itab-VKAUS,

/(30) 'Runtime Band description :', itab-BEZE_I,

/(30) 'Support Start Date :', itab-BSTDK,

/(30) 'Support End Date :', itab-BSTDK_E,

/(30) 'Support Level Code :', itab-KDKG2,

/(30) 'Support Level Desc :', itab-VTEXT2,

/(30) 'Order Quantity :', itab-KWMENG,

/(30) 'Net Price :', itab-NETWR,

/(30) 'Currency :', itab-WAERK.

uline.

ENDLOOP.

if sy-subrc <> 0.

write : / 'No data found'.

endif.

8 REPLIES 8
Read only

Former Member
0 Likes
1,169

Hi budy,

well done... no one can do coding better then u.. go ahead...

Read only

Former Member
0 Likes
1,169

hi jyoti,

After the select statements i.e fetching the data u must read ur internal table by using commands such as loop or read table for detail syntax check abapdocu tcode.

Reward points if helpful,

Regards,

Sumanjeet.

Read only

former_member402443
Contributor
0 Likes
1,169

Hi Jyotirmoy Deb,

Last time might be,you are the one that asking about using join statement on 3 tables.

Now what are you doing in your code. use are joining almost 18 tables.this will not work anyone, and it will slow down the processing time of the report.

First of all analysis the report what exactly you want and then

first read the header data as in your case you using the Sale Document Header data.

On the basis of Header data fetch the line item data.

Don't processes all the tables at a time using the join clause.Because it decrease the efficiency of the program.

Reward points,if useful.

Regards,

Manoj Kumar

Read only

0 Likes
1,169

Hi Manoj,

Thanks to reply.

What will be the approach tell me !

what is want is against vbeln i want to retrieve all the other data from the other fields.

Will this give wrong data !

Read only

0 Likes
1,169

Hi Jyotirmoy Deb,

As you specified tables in your code. will you require data from all the table .

Will u tell me what are the fields u required to be display and which table they belong

Regards,

Manoj Kumar

Read only

0 Likes
1,169

i need data from all the tables as given here and the corresponding fields are also given....

How to fetch data at a time from all of them !

Read only

Former Member
0 Likes
1,169

Hi,

Can u tell what exactly u r doing and there is table into which u r passing the data can i guess u could not activated the program due to errors, and the sy-subrc should be immediately after the select statement.

Goto to t-code abapdocu and see some examples.

If u have any queries post me to .Plzz reward points if it helps.

Read only

Former Member
0 Likes
1,169

Hi,

Here you yourself declared the structure of internal table ITAB, then try to remove the "INTO CORRESPONDING FIELDS OF", i am not saying it is wrong, but coming to the performance wise it will take lot of time.

try to change the order of the fields in your structure, which should be matched to the order of the fields that you are fetching from the select statement.

Make sure that the oreder of the fields in your structure and the fetching fields from the select statement should be in same order otherwise you will get short dump.

Reward if useful.

Thanks,

Sreeram.