‎2008 Dec 24 11:48 AM
Hi Guru's.
i have develop report for annexure 5 . all data come properly.
but only mseg table table data not come, only first record display .
my code.
loop at it_vbap.
read table it_vbap with key
vbeln = it_vbak-vbeln
posnr = it_vbap-posnr.
if sy-subrc = 0.
read table it_vbep with key
vbeln = it_vbap-vbeln
posnr = it_vbap-posnr.
if sy-subrc = 0.
read table it_mseg with key
mat_kdauf = it_vbap-vbeln
BWART = '501'
SOBKZ = 'E'.
if sy-subrc = 0.
IT_ANN-vbeln = it_vbak-vbeln.
IT_ANN-kunnr = it_vbak-kunnr.
IT_ANN-kwmeng = it_vbap-kwmeng.
IT_ANN-lsmeng = it_vbap-lsmeng.
IT_ANN-posnr = it_vbap-posnr.
IT_ANN-matnr = it_vbap-matnr.
IT_ANN-arktx = it_vbap-arktx.
IT_ANN-edatu = it_vbep-edatu.
IT_ANN-prsdt = it_vbkd-prsdt.
IT_ANN-mblnr = it_mseg-mblnr.
IT_ANN-mat1 = it_mseg-matnr.
IT_ANN-lifnr = it_mseg-lifnr.
IT_ANN-erfmg = it_mseg-erfmg.
IT_ANN-sgtxt = it_mseg-sgtxt.
append it_ann.
endif.
endif.
endif.
endloop.
Thanks in Advance.
Regard
Sam.
Edited by: sam on Dec 24, 2008 12:48 PM
‎2008 Dec 24 11:51 AM
loop at it_vbaK. " This should be it_VBAK & not it_VBAP
read table it_vbap with key
vbeln = it_vbak-vbeln
posnr = it_vbak-posnr. "should be it_vbak
if sy-subrc = 0.
read table it_vbep with key
vbeln = it_vbap-vbeln
posnr = it_vbap-posnr.
if sy-subrc = 0.
read table it_mseg with key
mat_kdauf = it_vbap-vbeln
BWART = '501' " Check in debug whether it_mseg has these values of VBELN, 501, E
SOBKZ = 'E'.
if sy-subrc = 0.
IT_ANN-vbeln = it_vbak-vbeln.
IT_ANN-kunnr = it_vbak-kunnr.
IT_ANN-kwmeng = it_vbap-kwmeng.
IT_ANN-lsmeng = it_vbap-lsmeng.
IT_ANN-posnr = it_vbap-posnr.
IT_ANN-matnr = it_vbap-matnr.
IT_ANN-arktx = it_vbap-arktx.
IT_ANN-edatu = it_vbep-edatu.
IT_ANN-prsdt = it_vbkd-prsdt.
IT_ANN-mblnr = it_mseg-mblnr.
IT_ANN-mat1 = it_mseg-matnr.
IT_ANN-lifnr = it_mseg-lifnr.
IT_ANN-erfmg = it_mseg-erfmg.
IT_ANN-sgtxt = it_mseg-sgtxt.
append it_ann.
endif.
endif.
endif.
endloop.Edited by: Prashant Patil on Dec 24, 2008 5:22 PM
‎2008 Dec 24 11:51 AM
loop at it_vbaK. " This should be it_VBAK & not it_VBAP
read table it_vbap with key
vbeln = it_vbak-vbeln
posnr = it_vbak-posnr. "should be it_vbak
if sy-subrc = 0.
read table it_vbep with key
vbeln = it_vbap-vbeln
posnr = it_vbap-posnr.
if sy-subrc = 0.
read table it_mseg with key
mat_kdauf = it_vbap-vbeln
BWART = '501' " Check in debug whether it_mseg has these values of VBELN, 501, E
SOBKZ = 'E'.
if sy-subrc = 0.
IT_ANN-vbeln = it_vbak-vbeln.
IT_ANN-kunnr = it_vbak-kunnr.
IT_ANN-kwmeng = it_vbap-kwmeng.
IT_ANN-lsmeng = it_vbap-lsmeng.
IT_ANN-posnr = it_vbap-posnr.
IT_ANN-matnr = it_vbap-matnr.
IT_ANN-arktx = it_vbap-arktx.
IT_ANN-edatu = it_vbep-edatu.
IT_ANN-prsdt = it_vbkd-prsdt.
IT_ANN-mblnr = it_mseg-mblnr.
IT_ANN-mat1 = it_mseg-matnr.
IT_ANN-lifnr = it_mseg-lifnr.
IT_ANN-erfmg = it_mseg-erfmg.
IT_ANN-sgtxt = it_mseg-sgtxt.
append it_ann.
endif.
endif.
endif.
endloop.Edited by: Prashant Patil on Dec 24, 2008 5:22 PM
‎2008 Dec 24 11:53 AM
try this code.
loop at it_vbap.
read table it_mseg with key
mat_kdauf = it_vbap-vbeln
BWART = '501'
SOBKZ = 'E'.
if sy-subrc = 0.
IT_ANN-mblnr = it_mseg-mblnr.
IT_ANN-mat1 = it_mseg-matnr.
IT_ANN-lifnr = it_mseg-lifnr.
IT_ANN-erfmg = it_mseg-erfmg.
IT_ANN-sgtxt = it_mseg-sgtxt.
append it_ann.
clear it_ann.
endif.
endloop.
‎2008 Dec 24 11:54 AM
Hi Sam,
the coding you have done is wrong thats why the output is not coming .
Do it in this way.
loop at it_vbak.
IT_ANN-vbeln = it_vbak-vbeln.
IT_ANN-kunnr = it_vbak-kunnr.
read table it_vbap with key
vbeln = it_vbak-vbeln
posnr = it_vbap-posnr.
if sy-subrc = 0.
IT_ANN-kwmeng = it_vbap-kwmeng.
IT_ANN-lsmeng = it_vbap-lsmeng.
IT_ANN-posnr = it_vbap-posnr.
IT_ANN-matnr = it_vbap-matnr.
IT_ANN-arktx = it_vbap-arktx.
endif.
read table it_vbep with key
vbeln = it_vbap-vbeln
posnr = it_vbap-posnr.
if sy-subrc = 0.
IT_ANN-edatu = it_vbep-edatu.
endif.
read table it_mseg with key
mat_kdauf = it_vbap-vbeln
BWART = '501'
SOBKZ = 'E'.
if sy-subrc = 0.
IT_ANN-mblnr = it_mseg-mblnr.
IT_ANN-mat1 = it_mseg-matnr.
IT_ANN-lifnr = it_mseg-lifnr.
IT_ANN-erfmg = it_mseg-erfmg.
IT_ANN-sgtxt = it_mseg-sgtxt.
endif.
append it_ann.
endloop
Thanks,
Chidanand
‎2008 Dec 24 11:54 AM
Hi
when you use read table key word in a loop it always gives the first record only.
if possible
loop at itab.
loop at i_mseg where matnr = itab-matnr.
*Here you can get all the records against the matnr or main loop
endloop
endloop
Regards
Ramchander Rao.k
‎2008 Dec 24 11:56 AM
Hi,
read table it_vbap with key -
> is it it_vbak or it_vbap (if it_vbap this read is not required)
vbeln = it_vbak-vbeln -
> it must be it_vbap
posnr = it_vbap-posnr.
if sy-subrc = 0.
read table it_vbep with key
vbeln = it_vbap-vbeln
posnr = it_vbap-posnr.
if sy-subrc = 0.
read table it_mseg with key -
> check the sy-subrc condition here.
mat_kdauf = it_vbap-vbeln
BWART = '501'
SOBKZ = 'E'.
Regards
Bala Krishna