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: 

very urgent: reterving data from table MKPF table

Former Member
0 Kudos

hi,

i am facing a problem in adding a code i.e. i am having a select statement which use to reterive data from MKPF but i am not able to fetch it as there,i had written code for the RSEG from where i get the Material Document No..

but now i have to take the value from the MKPF as well as it is the requierment of the code.

here is the following code which i am using right now is to reterive data from RSEG :-

SELECT BUKRS BELNR GJAHR AWKEY BUDAT XBLNR

AWTYP FROM BKPF

INTO (ITBKPF-BUKRS,ITBKPF-BELNR,ITBKPF-GJAHR,

ITBKPF-AWKEY,ITBKPF-BUDAT,ITBKPF-XBLNR,ITBKPF-AWTYP)

WHERE AWTYP EQ 'MKPF' OR AWTYP EQ 'RMRP'.

**BEGIN OF TRY CODE FOR A MATERIAL DOCUMENT**

ITDEMO-BELNR = ITBKPF-AWKEY(10).

ITDEMO-GJAHR = ITBKPF-AWKEY+10(4).

ITDEMO-XBLNR = ITBKPF-XBLNR.

SELECT LFBNR FROM RSEG INTO

(ITDEMO-LFBNR) WHERE

BELNR EQ ITBKPF-AWKEY(10) AND

GJAHR EQ ITBKPF-AWKEY+10(4) AND

XBLNR EQ ITBKPF-XBLNR AND LFBNR > 0.

CHECK SY-SUBRC EQ 0 AND ITDEMO-LFBNR IN P_LFBNR.

**END OF TRY CODE FOR A MATERIAL DOCUMENT**

Edited by: abaper2008 on Jun 10, 2008 7:42 AM

4 REPLIES 4

Former Member
0 Kudos

Hi,

check with the below code

TYPES : BEGIN OF t_bkpf,

bukrs TYPE bukrs,

blenr TYPE belnr_d,

gjahr TYPE gjahr,

awkey TYPE awkey,

budat TYPE budat,

xblnr TYPE xblnr1,

awtyp TYPE awtyp,

END OF t_bkpf,

BEGIN OF t_demo,

belnr TYPE belnr_d,

gjahr TYPE gjahr,

xblnr TYPE xblnr,

lfbnr TYPE lfbnr,

END OF t_demo.

DATA: itbkpf TYPE t_bkpf,

itdemo TYPE t_demo.

TABLES: rseg.

SELECT-OPTIONS: p_lfbnr FOR rseg-lfbnr.

start-of-selection.

SELECT SINGLE bukrs belnr gjahr awkey budat xblnr

awtyp FROM bkpf

INTO itbkpf

WHERE awtyp EQ 'MKPF' OR awtyp EQ 'RMRP'.

**BEGIN OF TRY CODE FOR A MATERIAL DOCUMENT**

itdemo-belnr = itbkpf-awkey(10).

itdemo-gjahr = itbkpf-awkey+10(4).

itdemo-xblnr = itbkpf-xblnr.

SELECT SINGLE lfbnr FROM rseg INTO

itdemo-lfbnr WHERE

belnr EQ itdemo-belnr AND

gjahr EQ itdemo-gjahr .

CHECK sy-subrc EQ 0 .

Regards,

Sriram.

0 Kudos

Hi,

dis the code for the rseg table and it was posted by me but the thing i want to fetch the data from MKPF ,but i dont knwo what type of ELSEIF should i write for it?

0 Kudos

Hi,

extract EBELN and EBLP from RSEG table

based on EBELN and EBELP read document data from MSEG table.

get MKPF data u can find based on MSEG entries.

Regards,

sriram

Edited by: Srirama Murthy Maddirala on Jun 10, 2008 8:15 AM

0 Kudos

hi,

i had deveoped a code for it,is correct or not?

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

DATA: BEGIN OF ITBKPF OCCURS 0,

BUKRS LIKE BKPF-BUKRS,

BELNR LIKE BKPF-BELNR,

GJAHR LIKE BKPF-GJAHR,

AWKEY LIKE BKPF-AWKEY,

BUDAT LIKE BKPF-BUDAT,

XBLNR LIKE BKPF-XBLNR,

AWTYP LIKE BKPF-AWTYP,

END OF ITBKPF.

DATA: BEGIN OF ITDEMO OCCURS 0,

BELNR LIKE RSEG-BELNR,

GJAHR LIKE RSEG-GJAHR,

LFBNR LIKE RSEG-LFBNR,

XBLNR LIKE RSEG-XBLNR,

END OF ITDEMO.

*******TABLE MKPF - FOR MATERIAL DOCUMENT*********

DATA: BEGIN OF ITDEMO1 OCCURS 0,

MBLNR LIKE MKPF-MBLNR,

MJAHR LIKE MKPF-MJAHR,

XBLNR LIKE MKPF-XBLNR,

END OF ITDEMO1.

START-OF-SELECTION.

  • BKPF

SELECT BUKRS BELNR GJAHR AWKEY BUDAT XBLNR AWTYP

FROM BKPF

INTO (ITBKPF-BUKRS,ITBKPF-BELNR,ITBKPF-GJAHR, ITBKPF-AWKEY,ITBKPF-BUDAT,ITBKPF-XBLNR,ITBKPF-AWTYP)

WHERE AWTYP EQ 'MKPF' OR AWTYP EQ 'RMRP'.

    • MKPF

*BEGIN OF TRY CODE FOR A MATERIAL DOCUMENT*

**begin- for bsis to be reterived**

IF ITBKPF-AWTYP EQ 'MKPF'.

ITDEMO1-MBLNR = ITBKPF-AWKEY(10).

ITDEMO1-MJAHR = ITBKPF-AWKEY+10(4).

ITDEMO1-XBLNR = ITBKPF-XBLNR.

SELECT SINGLE MBLNR FROM MKPF INTO (ITDEMO1-MBLNR)

WHERE MBLNR EQ ITBKPF-AWKEY(10)

AND MJAHR EQ ITBKPF-AWKEY+10(4) AND XBLNR > 0.

CHECK SY-SUBRC EQ 0 AND ITDEMO1-MBLNR IN P_LFBNR.

**end - for bsis to be reterived**

ELSE.

ITDEMO-BELNR = ITBKPF-AWKEY(10).

ITDEMO-GJAHR = ITBKPF-AWKEY+10(4).

ITDEMO-XBLNR = ITBKPF-XBLNR.

SELECT LFBNR FROM RSEG INTO

(ITDEMO-LFBNR) WHERE

BELNR EQ ITBKPF-AWKEY(10) AND

GJAHR EQ ITBKPF-AWKEY+10(4) AND

XBLNR EQ ITBKPF-XBLNR AND LFBNR > 0.

CHECK SY-SUBRC EQ 0 AND ITDEMO-LFBNR IN P_LFBNR.

    • END OF TRY CODE FOR A MATERIAL DOCUMENT**

APPEND ITDEMO1.

EXIT.

ENDSELECT.

ENDIF.

APPEND ITDEMO.

EXIT.

ENDSELECT.

APPEND ITBKPF.

ENDSELECT.

Edited by: abaper2008 on Jun 10, 2008 10:19 AM