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:ย 

Execute the Program

Former Member
0 Kudos

Hello Friends,

Execute the program in your systems and check that it is showing the last data, i want the entire data. And also make sure that EKPO table data is not coming make some corrections in that. its very urgent help me soon.

THANK YOU

Girish.

*&----


-


*

*& Report ZTABLEREPORT *

*& *

&----


*& *

*& *

&----


REPORT ztablereport NO STANDARD PAGE HEADING

LINE-SIZE 250

LINE-COUNT 22(3).

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

  • TABLES DECLARATION *

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

TABLES : mara, "general material data

makt, "material description

marc, "plant data for material

vbap, "sales document for item data

ekko, "purchasing document header

ekpo, "purchasing document item

kna1. "customer master details

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

  • INTERNAL TABLE DECLARATION *

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

TYPES: BEGIN OF ty_mara,

matnr TYPE matnr,

mtart TYPE mtart,

meins TYPE meins,

kunnr TYPE wettb,

END OF ty_mara.

TYPES: BEGIN OF ty_makt,

matnr TYPE matnr,

maktx TYPE maktx,

spras TYPE spras,

END OF ty_makt.

TYPES: BEGIN OF ty_marc,

matnr TYPE matnr,

werks TYPE werks_d,

END OF ty_marc.

TYPES : BEGIN OF ty_kna1,

kunnr TYPE kunnr,

name1 TYPE name1_gp,

land1 TYPE land1_gp,

END OF ty_kna1.

TYPES: BEGIN OF ty_vbap,

matnr TYPE matnr,

posnr TYPE posnr_va,

matkl TYPE matkl,

vbeln TYPE vbeln_va,

END OF ty_vbap.

TYPES: BEGIN OF ty_ekpo,

ebeln TYPE ebeln,

ebelp TYPE ebelp,

bukrs TYPE bukrs,

werks TYPE werks_d,

lgort TYPE lgort_d,

matnr TYPE matnr,

mandt TYPE mandt,

END OF ty_ekpo.

DATA:t_mara TYPE TABLE OF ty_mara WITH HEADER LINE,

t_makt TYPE TABLE OF ty_makt WITH HEADER LINE,

t_marc TYPE TABLE OF ty_marc WITH HEADER LINE,

t_kna1 TYPE TABLE OF ty_kna1 WITH HEADER LINE,

t_vbap TYPE TABLE OF ty_vbap WITH HEADER LINE,

t_ekpo TYPE TABLE OF ty_ekpo WITH HEADER LINE.

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

  • FINAL INTERNAL TABLE *

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

TYPES: BEGIN OF ty_final,

matnr TYPE matnr,

mtart TYPE mtart,

meins TYPE meins,

werks TYPE werks_d,

maktx TYPE maktx,

spras TYPE spras,

vbeln TYPE vbeln_va,

posnr TYPE posnr_va,

matkl TYPE matkl,

ebeln TYPE ebeln,

ebelp TYPE ebelp,

bukrs TYPE bukrs,

kunnr TYPE kunnr,

land1 TYPE land1_gp,

name1 TYPE name1_gp,

lgort TYPE lgort_d,

END OF ty_final.

DATA : t_final TYPE TABLE OF ty_final WITH HEADER LINE.

*DATA: BEGIN OF V_matnr OCCURS 0,

  • matnr LIKE mara-matnr,

  • END OF t_matnr.

DATA:

a(32) TYPE c.

a = 'IBT000000000000000001000000000000000050'.

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

  • SELECTION SCREEN *

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

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

SELECT-OPTIONS : s_bukrs FOR ekpo-bukrs,

s_kunnr FOR kna1-kunnr,

s_werks FOR marc-werks,

s_matnr FOR mara-matnr OBLIGATORY.

SELECTION-SCREEN END OF BLOCK b1.

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

  • START OF SELECTION *

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

START-OF-SELECTION.

*USE SUBROUTINES

*get data

PERFORM get_data.

*populate final table

PERFORM populate_final_table.

END-OF-SELECTION.

*display output

PERFORM display_output.

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

  • TOP-OF-PAGE *

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

TOP-OF-PAGE.

ULINE.

WRITE : /60 'G E N E R A L D E T A I L S' COLOR 2 INVERSE OFF.

ULINE.

WRITE ๐Ÿ˜• sy-vline, 'MATERIAL' COLOR 4, "12 SY-VLINE,

13 sy-vline, 'IND SECTOR',

28 sy-vline, 'UNITS',

43 sy-vline, 'PLANT',

55 sy-vline, 'MAT DESC',

68 sy-vline, 'LANGU',

70 sy-vline, 'SALES DOC ITEM',

95 sy-vline, 'MAT GROUP',

110 sy-vline, 'SALES DOC',

125 sy-vline, 'CUST ID',

140 sy-vline, 'NAME',

155 sy-vline, 'COUNTRY',

165 sy-vline, 'company code',

205 sy-vline, 'storge loc'.

&----


*& Form GET_DATA

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


*TRY TO CLEAR AND REFRESH TABLES BEFORE SELECT

FORM get_data .

CLEAR t_mara.

REFRESH t_mara.

SELECT matnr

mtart

meins

kunnr

FROM mara

INTO TABLE t_mara

WHERE matnr IN s_matnr.

IF NOT t_mara[] IS INITIAL.

CLEAR t_marc.

REFRESH t_marc.

SELECT matnr

werks

FROM marc

INTO TABLE t_marc

FOR ALL ENTRIES IN t_mara

WHERE matnr = t_mara-matnr

AND werks IN s_werks.

CLEAR t_makt.

REFRESH t_makt.

SELECT matnr

maktx

spras

FROM makt

INTO TABLE t_makt

FOR ALL ENTRIES IN t_mara

WHERE matnr = t_mara-matnr

AND spras = sy-langu.

CLEAR t_vbap.

REFRESH t_vbap.

SELECT matnr

posnr

matkl

vbeln

FROM vbap

INTO TABLE t_vbap

FOR ALL ENTRIES IN t_mara

WHERE matnr = t_mara-matnr.

CLEAR t_ekpo.

REFRESH t_ekpo.

SELECT ebeln

ebelp

bukrs

werks

lgort

matnr

mandt

FROM ekpo

INTO TABLE t_ekpo

FOR ALL ENTRIES IN t_mara

WHERE matnr = t_mara-matnr

AND werks IN s_werks.

ENDIF.

CLEAR t_kna1.

REFRESH t_kna1.

SELECT kunnr

land1

name1

INTO TABLE t_kna1

FROM kna1.

  • WHERE WERKS in s_werks.

ENDFORM. " GET_DATA

&----


*& Form POPULATE_FINAL_TABLE

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM populate_final_table .

*AVOID LOOPS AND TRY TO USE READ

CLEAR t_final.

REFRESH t_final.

LOOP AT t_mara.

MOVE t_mara-matnr TO t_final-matnr.

MOVE t_mara-mtart TO t_final-mtart.

MOVE t_mara-meins TO t_final-meins.

READ TABLE t_marc WITH KEY matnr = t_mara-matnr.

MOVE t_marc-werks TO t_final-werks.

READ TABLE t_makt WITH KEY matnr = t_mara-matnr.

MOVE t_makt-maktx TO t_final-maktx.

MOVE t_makt-spras TO t_final-spras.

READ TABLE t_vbap WITH KEY matnr = t_mara-matnr.

MOVE t_vbap-posnr TO t_final-posnr.

MOVE t_vbap-matkl TO t_final-matkl.

MOVE t_vbap-vbeln TO t_final-vbeln.

READ TABLE t_ekpo WITH KEY matnr = t_mara-matnr.

MOVE t_ekpo-bukrs TO t_final-bukrs.

MOVE t_ekpo-ebeln TO t_final-ebeln.

MOVE t_ekpo-ebelp TO t_final-ebelp.

MOVE t_ekpo-lgort TO t_final-lgort.

READ TABLE t_kna1 WITH KEY kunnr = t_mara-kunnr.

MOVE t_kna1-kunnr TO t_final-kunnr.

MOVE t_kna1-name1 TO t_final-name1.

MOVE t_kna1-land1 TO t_final-land1.

APPEND t_final.

CLEAR :t_final,t_mara,t_marc,t_makt,t_ekpo,t_vbap.

ENDLOOP.

ENDFORM. " POPULATE_FINAL_TABLE

&----


*& Form DISPLAY_OUTPUT

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM display_output .

LOOP AT t_final.

WRITE : 4 t_final-matnr,

20 t_final-mtart,

28 t_final-meins,

46 t_final-werks,

58 t_final-maktx,

71 t_final-spras,

78 t_final-posnr,

100 t_final-matkl,

115 t_final-vbeln,

130 t_final-kunnr,

142 t_final-name1,

156 t_final-land1,

168 t_final-bukrs,

190 t_final-ebeln,

205 t_final-ebelp,

208 t_final-lgort.

ENDLOOP.

ENDFORM. " DISPLAY_OUTPUT

6 REPLIES 6

Former Member
0 Kudos

You have to use LOOP ... ENDLOOP instead of your existing READ statments. You can have multiple POs for the same material and so are MARC records and VBAP records. MAKT, you can avoid the loop if you have descriptions maintained in only one language.

Make these corrections and see if you are not getting the correct data.

Srinivas

Former Member
0 Kudos

The problem is with the write statement you are using in the Loop. Please use

Write:/ instead of write :. It will overwrite the line in the loop.

Hope this helps.

Former Member
0 Kudos

Please don't forget to reward and close all your other posts here.

https://forums.sdn.sap.com/profile.jspa?userID=1996003&start=0

Former Member
0 Kudos

Since you are presenting both sales order items and PO items on the same line, I think you also need some logic to determine how they go together.

Rob

0 Kudos

In addition, you are not using an index on VBAP. This could be very expensive in a production system. In your earlier post, I suggested going to MSEG first. I still think you should do that.

Rob

Former Member
0 Kudos

Hi,

I am getting data for EKPO fields in my system.

In form display_ouput change the write statement ad <b>write : /</b> instead of <b>write : </b>

&----


*& Form DISPLAY_OUTPUT

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM display_output .

LOOP AT t_final.

<b>WRITE : /4 t_final-matnr,</b>

20 t_final-mtart,

28 t_final-meins,

46 t_final-werks,

58 t_final-maktx,

71 t_final-spras,

78 t_final-posnr,

100 t_final-matkl,

115 t_final-vbeln,

130 t_final-kunnr,

142 t_final-name1,

156 t_final-land1,

168 t_final-bukrs,

190 t_final-ebeln,

205 t_final-ebelp,

208 t_final-lgort.

ENDLOOP.

ENDFORM. " DISPLAY_OUTPUT