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

mseg table data not retrive

Former Member
0 Likes
2,016

Hi Guru's,

I have retrieve data using read table . but in that mseg table data display but only first record repeated three time.

my select query like this.

SELECT * FROM MSEG

INTO CORRESPONDING FIELDS

OF TABLE IT_MSEG for all entries in it_vbap

WHERE MAT_KDAUF = it_vbap-vbeln

AND BWART = '501'

AND SOBKZ = 'E'.

and after that i have read table like this

loop at it_vbap where vbeln = it_vbak-vbeln.

read table it_kna1 with key

kunnr = it_vbak-kunnr.

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.

read table it_mkpf with key

mblnr = it_mseg-mblnr.

if sy-subrc = 0.

read table it_MAKT with key

MATNR = it_MSEG-MATNR.

if sy-subrc = 0.

read table it_lips with key

vgbel = it_vbap-vbeln

posnv = it_vbap-posnr.

if sy-subrc = 0.

IT_ANN-vbeln = it_vbak-vbeln.

IT_ANN-name1 = it_kna1-name1.

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.

IT_ANN-BUDAT = it_mkpf-BUDAT.

IT_ANN-lfimg = it_lips-lfimg.

IT_ANN-MAKTX = it_MAKT-MAKTX.

append it_ann.

endif.

endif.

endif.

endif.

endif.

endif.

endloop.

where i am wrong.

please help me.

Thanks in Advance.

Regard.

Sam.

1 ACCEPTED SOLUTION
Read only

GuyF
Active Participant
0 Likes
1,966

Hi

Try the following code:

loop at it_vbap where vbeln = it_vbak-vbeln.
  IT_ANN-vbeln = it_vbak-vbeln.

  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-prsdt = it_vbkd-prsdt.

  read table it_kna1 with key kunnr = it_vbak-kunnr.
  if sy-subrc = 0.
    IT_ANN-name1 = it_kna1-name1.
  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_MAKT with key MATNR = it_MSEG-MATNR.
  if sy-subrc = 0.
    IT_ANN-MAKTX = it_MAKT-MAKTX.
  endif.

  read table it_lips with key vgbel = it_vbap-vbeln
                              posnv = it_vbap-posnr.
  if sy-subrc = 0.
    IT_ANN-lfimg = it_lips-lfimg.
  endif.

  loop at it_mseg where mat_kdauf = it_vbap-vbeln.
    read table it_mkpf with key mblnr = it_mseg-mblnr.
    if sy-subrc = 0.
      IT_ANN-BUDAT = it_mkpf-BUDAT.
    endif.

    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.
  endloop.
endloop.

Best Regards,

Guy

Edited by: Guy F. on Dec 26, 2008 11:03 AM

16 REPLIES 16
Read only

Former Member
0 Likes
1,966

Hi,

I think you have compare another field at the time of selection and read also i.e.

MSEG-MAT_KDPOS = VBAP-POSNR

Arunima

Read only

Former Member
0 Likes
1,966

hi.

i don understand wat kind of output you want but

if you don want mseg data to be repeated, then whnever you will find entry in mseg table while reading the mseg table take that sy-tabix value in some other variable and at the end of the if condition ie when your 'endif' of your 'sy-subrc = 0' check comes, delete the entry from internal mseg table after processing which wont repeat further if you dont want.

hope this is you want

Read only

Former Member
0 Likes
1,966

Hi

If you are using READ key word it gets only the first available record.

loop at i_scarr.

read table i_sflight where carrid = i_scarr-carrid.

obviously SFLIGHT has more number of records for a given carrid

Please check the tables SCARR and SFLIGHT

endloop.

in your case you need to do like this

loop at i_scarr.

loop at i_sflight where carrid = i_scarr-carrid.

endloop.

endloop

or loop the Item interanal table if you have more records in item than header table

if I_VBAP has different MATNR then change your READ statement as follows

read table it_mseg with key

mat_kdauf = it_vbap-vbeln

matnr = it_vbap-matnr " Might be helpful

BWART = '501'

SOBKZ = 'E'.

Read only

Former Member
0 Likes
1,966

Hi sam,

actually the condition that you use at loop statement..

here "loop at it_vbap where vbeln = it_vbak-vbeln."

it_vbak-vbeln has same value so you are getting repeated records.

please you propercondtion.

i think you will get record according to last record value in it_vbap .

Read only

0 Likes
1,966

Hi Swati,

Thanks for answer .

Could you tell me which condition i use here.

Sam.

Read only

Former Member
0 Likes
1,966

hi sam did you get the point where it was wrong.

Read only

Former Member
0 Likes
1,966

hi use..

loop at it_vbak.

loop at it_vbap where vbeln = it_vbak-vbeln.

clear it_vbap .

endloop.

clear it_vbak.

endloop.

Edited by: swati gupta on Dec 26, 2008 8:02 AM

Read only

0 Likes
1,966

hi sam,

is your problem solved r not..

please let me know abt that..

Read only

0 Likes
1,966

hi swati

your suggestion not work.

problem occurred same.

sam.

Read only

0 Likes
1,966

hello sam,

i had mentioned before that you have to match the line item also....have you tried that???

Arunima

Read only

0 Likes
1,966

hi please check the entries in it_vbak..

by using debugging..you wll get the solution..and please update me result

Read only

0 Likes
1,966

Hi

I tried that but item not same

menace mseg-mat_kdpos and vbap-posnr not same.

Regard

Sam.

Read only

0 Likes
1,966

Hi Swati,

I also debugge code .

1)in it_vbak one record.

2)it_vbap three record

3)and it_mseg 3 record

but when dubugge code

1 and 2 correct but last one only display 1 record three time.

Regards.

Sam.

Read only

0 Likes
1,966

hi sam

when it_vbap has one record ,then you will get the same data according to that record.

so you use different condition..

you let me know your req?

..

Read only

0 Likes
1,966

Hi

I want to develop Annexure V report.

In that i want MIGO related record,

like sales order no, customer , material , order quantity, del. quantity, raw material, posting date , posting quantity, vendor , invoice text.

Regard.

Sam

Edited by: sam on Dec 26, 2008 10:01 AM

Read only

GuyF
Active Participant
0 Likes
1,967

Hi

Try the following code:

loop at it_vbap where vbeln = it_vbak-vbeln.
  IT_ANN-vbeln = it_vbak-vbeln.

  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-prsdt = it_vbkd-prsdt.

  read table it_kna1 with key kunnr = it_vbak-kunnr.
  if sy-subrc = 0.
    IT_ANN-name1 = it_kna1-name1.
  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_MAKT with key MATNR = it_MSEG-MATNR.
  if sy-subrc = 0.
    IT_ANN-MAKTX = it_MAKT-MAKTX.
  endif.

  read table it_lips with key vgbel = it_vbap-vbeln
                              posnv = it_vbap-posnr.
  if sy-subrc = 0.
    IT_ANN-lfimg = it_lips-lfimg.
  endif.

  loop at it_mseg where mat_kdauf = it_vbap-vbeln.
    read table it_mkpf with key mblnr = it_mseg-mblnr.
    if sy-subrc = 0.
      IT_ANN-BUDAT = it_mkpf-BUDAT.
    endif.

    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.
  endloop.
endloop.

Best Regards,

Guy

Edited by: Guy F. on Dec 26, 2008 11:03 AM