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

error while selecting data for mara table from KOTG516 table

Former Member
0 Likes
533

Hello all,

I am trying to select the data from mara table with respect to KOTG516 table . but i am not getting the value into t_mara table as t_kotg516-matnr is empty . but the t_kotg516 conatins the matnr value . here is the code . i am not getting where i went wrong . please help .

TYPES: BEGIN OF Y_KOTG516,

KAPPL TYPE KAPPL,

KSCHL TYPE KSCHG,

VKORG TYPE VKORG,

VTWEG TYPE VTWEG,

KUNAG TYPE KUNAG,

MATNR TYPE MATNR,

DATBI TYPE KODATBI,

END OF Y_KOTG516.

DATA: T_KOTG516 TYPE STANDARD TABLE OF Y_KOTG516,

E_KOTG516 TYPE Y_KOTG516.

TYPES: BEGIN OF Y_MARA,

MATNR TYPE MATNR,

MEINS TYPE MEINS,

END OF Y_MARA.

DATA: T_MARA TYPE STANDARD TABLE OF Y_MARA,

E_MARA TYPE Y_MARA.

SELECT KAPPL

KSCHL

VKORG

VTWEG

KUNAG

MATNR

DATBI

FROM KOTG516

INTO TABLE T_KOTG516

WHERE VKORG IN S_VKOR

AND VTWEG IN S_VTWE

AND KUNAG IN S_KUNAG.

IF NOT T_KOTG516[] IS NOT INITIAL

and SY-SUBRC EQ 0.

SELECT MATNR

MEINS

FROM MARA

INTO TABLE T_MARA

  • FOR ALL ENTRIES IN T_KOTG516

WHERE MATNR EQ T_KOTG516-MATNR

AND MEINS EQ 'CS'

OR MEINS EQ 'IT'.

ENDIF.

FOR T_KOTG516 I HAVE VALUE but matnr is not getting selected from mara table as i cheked t_kotg516-mara is empty . i cant use with header line . please advise .

Regards

3 REPLIES 3
Read only

Former Member
0 Likes
484

i think u had not define internal tables properly.......

do this way and check......

TYPES: BEGIN OF Y_KOTG516,

KAPPL TYPE KOTG516-KAPPL,

KSCHL TYPE KOTG516-KSCHG,

VKORG TYPE KOTG516-VKORG,

VTWEG TYPE KOTG516-VTWEG,

KUNAG TYPE KOTG516-KUNAG,

MATNR TYPE KOTG516-MATNR,

DATBI TYPE KOTG516-KODATBI,

END OF Y_KOTG516.

Read only

0 Likes
484

Hi ,

The error was with the intital code .. IF NOT T_KOTG516[] IS NOT INITIAL. ...It should be only IF NOT T_KOTG516[] IS INITIAL.

typo error while coding ..it was resolved .

and I think when u define a type structure better to use dateelements rather then referring to fields .m y quiry resolved ..

Read only

0 Likes
484

hi,

SELECT KAPPL

KSCHL

VKORG

VTWEG

KUNAG

MATNR

DATBI

FROM KOTG516

INTO TABLE T_KOTG516

WHERE VKORG IN S_VKOR

AND VTWEG IN S_VTWE

AND KUNAG IN S_KUNAG.

if sy-subrc = 0 .

SELECT MATNR

MEINS

FROM MARA

INTO TABLE T_MARA

FOR ALL ENTRIES IN T_KOTG516

WHERE MATNR EQ T_KOTG516-MATNR

AND MEINS EQ 'CS'

OR MEINS EQ 'IT'.

ENDIF.

regards

deepak .