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

REPORT

Former Member
0 Likes
869

hi

please help me to find the solution.

this is the logic :

DATA: BEGIN OF it_item_master OCCURS 10,

matnr LIKE mara-matnr,

maktx LIKE makt-maktx,

spart LIKE mara-spart,

pstyv LIKE vbap-pstyv,

prdha LIKE mara-prdha,

yyverpa LIKE marc-yyverpa,

yyfuellmg LIKE marc-yyfuellmg,

matkl LIKE mara-matkl,

END OF it_item_master.

SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.

SELECT-OPTIONS: s_matnr2 FOR mara-matnr,

s_vbeln2 FOR vbap-vbeln,

s_werks2 FOR marc-werks,

s_vkorg2 FOR knvp-vkorg.

SELECTION-SCREEN END OF BLOCK b2.

SELECT matnr spart prdha matkl

FROM mara

INTO CORRESPONDING FIELDS OF TABLE it_item_master

WHERE matnr IN s_matnr2.

SELECT yyverpa yyfuellmg

FROM marc

INTO CORRESPONDING FIELDS OF TABLE it_item_master

WHERE matnr IN s_matnr2

AND werks IN s_werks2.

SELECT pstyv

FROM vbap

INTO CORRESPONDING FIELDS OF TABLE it_item_master

WHERE vbeln IN s_vbeln2.

LOOP AT it_item_master.

APPEND it_item_master.

  • ENDLOOP.

WRITE:it_item_master-matnr,

it_item_master-spart,

it_item_master-prdha,

it_item_master-matkl,

it_item_master-maktx,

it_item_master-yyverpa,

it_item_master-yyfuellmg.

ENDLOOP.

i am not getting the data in to the internal table and moreever it is taking long time to come out of the loop.

plse guide me is this right way to retrive the data,is there any mistake? plse ...

with regards

narasimha rao

6 REPLIES 6
Read only

ibrahim_u
Active Participant
0 Likes
805

SELECT pstyv

FROM vbap

INTO CORRESPONDING FIELDS OF TABLE it_item_master

WHERE vbeln IN s_vbeln2.

LOOP AT it_item_master.

APPEND it_item_master. <<<<< WHY

  • ENDLOOP.

.

.

.

if you use "APPEND it_item_master" there, your loop never end.

you must delete this code.

ibrahim

Read only

Former Member
0 Likes
805

LOOP AT it_item_master.

<b>APPEND it_item_master</b>.---->not needed..

  • ENDLOOP.

WRITE:it_item_master-matnr,

it_item_master-spart,

it_item_master-prdha,

it_item_master-matkl,

it_item_master-maktx,

it_item_master-yyverpa,

it_item_master-yyfuellmg.

ENDLOOP.

not needed becoz ur recored is already in itab because u used into table itab in select query.

Read only

former_member480923
Active Contributor
0 Likes
805

Hi,

Problems in the code:

a) Why don't you try to create a Join of MARA and MARC to pick data into table it_item_master1 (temp table) and then for all entries of that pick data from VBAP into it_item_master2. Combine the datas of both the table into the final table it_item_master.

b)Theres a APPEND it_item_master in your loop before the write statemnet ??

c) Write a separate loop for your write and append statement.

Hope This Helps

Anirban

Read only

Former Member
0 Likes
805

all selects are strange.

you are deleting it_item_master table in next selects.(what you are getting in select with mara is deleteted by select by marc and.so on)

To get expectet results use Joins between tables MARA, MARC and VBAP.

BR< JAcek

Read only

Former Member
0 Likes
805

Hi,

Assuming you want the data in <b>it_item_master</b> into another internal table .

This is how you can do it.

Decalare another Internal Table <b>it_item_master_temp</b>

Consider this code.


DATA: BEGIN OF it_item_master OCCURS 10,
matnr LIKE mara-matnr,
maktx LIKE makt-maktx,
spart LIKE mara-spart,
pstyv LIKE vbap-pstyv,
prdha LIKE mara-prdha,
yyverpa LIKE marc-yyverpa,
yyfuellmg LIKE marc-yyfuellmg,
matkl LIKE mara-matkl,
END OF it_item_master.

<b>DATA : it_item_master_temp LIKE it_item_master OCCURS 0.</b>


SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
SELECT-OPTIONS: s_matnr2 FOR mara-matnr,
s_vbeln2 FOR vbap-vbeln,
s_werks2 FOR marc-werks,
s_vkorg2 FOR knvp-vkorg.
SELECTION-SCREEN END OF BLOCK b2.

SELECT matnr spart prdha matkl
FROM mara
INTO CORRESPONDING FIELDS OF TABLE it_item_master
WHERE matnr IN s_matnr2.
SELECT yyverpa yyfuellmg
FROM marc
INTO CORRESPONDING FIELDS OF TABLE it_item_master
WHERE matnr IN s_matnr2
AND werks IN s_werks2.

SELECT pstyv
FROM vbap
INTO CORRESPONDING FIELDS OF TABLE it_item_master
WHERE vbeln IN s_vbeln2.

LOOP AT it_item_master.

<b>*For Dispalying the data.</b>
  WRITE:it_item_master-matnr,
        it_item_master-spart,
        it_item_master-prdha,
        it_item_master-matkl,
        it_item_master-maktx,
        it_item_master-yyverpa,
        it_item_master-yyfuellmg.

<b>*For putting the data into another Internal Table</b>
  it_item_master_temp-matnr = it_item_maste-matnr .
  it_item_master_temp-spart = it_item_master-spart.
  it_item_master_temp-prdha = it_item_master-prdha.


  APPEND it_item_master_temp.
  CLEAR it_item_master_temp.


ENDLOOP.

Regards,

AS

Read only

Former Member
0 Likes
805

Use FORALLENTRIES statement and try it out