07-25-2008 12:21 PM
hi,
i want to select indent no. for a sales order no.
i m selecting vbeln from vbap table and joining it with eban-bednr vbap-vbeln = eban-benr
but by doing so no data is selected only vbap-vbeln is coming.
whether the join condition is wrong?
i have to show indent no for a sales order and its item.
here is the code.
&----
*& Report ZBOMTEST2 *
*& *
&----
*& *
*& *
&----
REPORT zbomtest2 NO STANDARD PAGE HEADING
LINE-SIZE 255. .
TABLES: vbak, vbap, vbkd , vbbe , kna1 , mara.
DATA: BEGIN OF ivbak OCCURS 0,
vbeln TYPE vbak-vbeln,
END OF ivbak.
DATA: BEGIN OF ivbap OCCURS 0,
vbeln TYPE vbap-vbeln,
posnr TYPE vbap-posnr,
kwmeng LIKE stko-bmeng ,
kosch TYPE vbap-kosch,
END OF ivbap.
DATA: BEGIN OF ieban OCCURS 0,
banfn TYPE eban-banfn,
bnfpo TYPE eban-bnfpo,
bednr TYPE eban-bednr,
matnr TYPE eban-matnr,
END OF ieban.
DATA: BEGIN OF itab OCCURS 0,
vbeln TYPE vbap-vbeln,
banfn TYPE eban-banfn,
bnfpo TYPE eban-bnfpo,
bednr TYPE eban-bednr,
matnr TYPE eban-matnr,
END OF itab.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.
SELECT-OPTIONS: s_vbeln FOR vbap-vbeln.
SELECTION-SCREEN END OF BLOCK b1.
START-OF-SELECTION.
SELECT vbeln posnr kwmeng kosch FROM vbap INTO CORRESPONDING FIELDS OF TABLE ivbap
WHERE vbeln IN s_vbeln.
IF NOT ivbap[] IS INITIAL.
SELECT banfn bnfpo bednr matnr FROM eban INTO TABLE ieban
FOR ALL ENTRIES IN ivbap WHERE bednr = ivbap-vbeln.
ENDIF.
LOOP AT ivbap.
READ TABLE ieban WITH KEY bednr = ivbap-vbeln.
IF sy-subrc = 0.
itab-banfn = ieban-banfn.
itab-bnfpo = ieban-bnfpo.
itab-bednr = ieban-bednr.
itab-matnr = ieban-matnr.
ENDIF.
itab-vbeln = ivbap-vbeln.
APPEND itab.
CLEAR itab.
ENDLOOP.
LOOP AT itab .
WRITE:/5 itab-vbeln , 16 itab-banfn , 30 itab-matnr.
ENDLOOP.
pls help....
regards
pankaj
07-25-2008 1:03 PM
Hi,
I think VBAK is relate dto Sales and EBAN is relaetd to Purchase requistion. they are not related to each other.
Based on your post, im considering the that VBELN(VBAP or VBAP) refers to BEDNR(EBAN).
I think for that VBELN there is no traacking number.
Do this way -
Frist get all entires in the Inertanal table (IT_EBAN) from EBAN with the tracking number.(BEDNR)
if IT_EBAN[] is not intital.
select the entries from VBAP dor all entires in IT_EBAN
where VEBLN = IT_EBAN-BEDNR.
endif.
This is reverse way of getting the things done.
If you still didnt get the values, then check wether this tracking number refers the sales document number or not.
If you still dont get the results, we can go with material number and other fields.
Thanks & Regards,
Chandralekha.
07-25-2008 1:22 PM
hi chandra lekha ,
i have tried that but still no data is coming .
IS joinining condition is ok?
i want to select indent no and items based on sales order.
regards
pankaj