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

types and data

Former Member
0 Likes
1,407

Hi,

i have to use both types and data without occurs n and i have to select the data from different tables and put in an internal table.Here is my code can any one modify this

Tables: mseg,mkpf,lfa1,ekko,ekpo,bseg,bkpf.

selection-screen begin of block b1 with frame title text-001.

parameters: p_werks like mseg-werks.

select-options: s_budat for Mkpf-budat.

selection-screen end of block b1.

types:begin of t_mseg,

p_werks type werks_d, "Plant location

mblnr type mblnr, "Number of Material Document

s_budat type budat, "Posting date in document

mtsnr type mtsnr1, "Number of external material slip

maktx type maktx, "Material description

menge type menge_d, "Quantity

lifnr type lifnr, "Vendor Number

name1 type name1_gp, "Name1

name2 type name2_gp, "Name2

telf1 type telf1, "Telephone number

trnam type ztrnam, "Transporter name

glano type zglano, "GR/LR/AWB No

J_1ICSTNO type J_1ICSTNO, "Central Sales Tax Number

J_1ILSTNO type J_1ILSTNO, "Local Sales Tax Number

J_1IEXRN type J_1IEXRN , "Excise Registration Number

end of t_mseg.

*data: begin of it_mseg ,

  • mblnr like mseg-mblnr,

  • budat like mkpf-budat,

  • mtsnr like gohead-mtsnr,

  • maktx like makt-maktx,

  • menge like mseg-menge,

  • lifnr like mseg-lifnr,

  • name1 like lfa1-name1,

  • name2 like lfa1-name2,

  • telf1 like lfa1-telf1,

  • trnam like zmigo_addition-trnam,

  • glano like zmigo_addition-glano,

  • end of it_mseg.

types: it_mseg type standard table of t_mseg,

wa_mseg type t_mseg.

select amblnr amatnr

amenge alifnr

b~budat

into it_mseg

from mseg as a

join mkpf as b

on amblnr = bmblnr

where werks = p_werks and

budat = s_budat.

append wa_MSEG to it_mseg.

endselect.

points will be given .

Thnaks in advance.

Regards,

Amit Teja.V

1 ACCEPTED SOLUTION
Read only

former_member480923
Active Contributor
0 Likes
1,366

Hi

Just one Modification

Instead of using the following

types: it_mseg type standard table of t_mseg,

use

data: it_mseg type standard table of t_mseg,

Hope this Helps

Anirban

12 REPLIES 12
Read only

Former Member
0 Likes
1,366

Hi amit,

1. I just tried your code.

2. do like this, and it will work.

3. remove the Type (2 lines)

and instead use DATA like this.

*types: it_mseg type standard table of t_mseg,

*wa_mseg type t_mseg.

<b>data : it_mseg type t_mseg occurs 0 with header line.

data : wa_mseg type t_mseg.</b>

regards,

amit m.

Read only

Former Member
0 Likes
1,366

<b>data:</b> it_mseg type standard table of t_mseg,

wa_mseg type t_mseg.

and

select amblnr amatnr

amenge alifnr

b~budat

into <b>table</b> it_mseg

from mseg as a

join mkpf as b

on amblnr = bmblnr

where werks = p_werks and

budat = s_budat.

Read only

Former Member
0 Likes
1,366

Declare the internal table as

<b>DATA</b>: it_mseg type standard table of t_mseg,

wa_mseg type t_mseg.

And not sure why you need the 'Append wa_mseg' statement? Data will be directly selected into the tab, you dont require a select-endselect there.

select amblnr amatnr

amenge alifnr

b~budat

into <b>table</b> it_mseg

from mseg as a

<b>inner</b> join mkpf as b

on amblnr = bmblnr

where werks = p_werks and

budat = s_budat.

Hope this helps.

Sudha

Message was edited by: Sudha Mohan

Read only

abdul_hakim
Active Contributor
0 Likes
1,366

hi use the below code..

Tables: mseg,mkpf,lfa1,ekko,ekpo,bseg,bkpf.

selection-screen begin of block b1 with frame title text-001.

parameters: p_werks like mseg-werks.

select-options: s_budat for Mkpf-budat.

selection-screen end of block b1.

types:begin of t_mseg,

mblnr type mseg-mblnr,

matnr type mara-matnr,

menge type mseg-menge,

lifnr type mseg-lifnr,

budat type mkpf-budat,

end of t_mseg.

types: it_mseg type standard table of t_mseg,

wa_mseg type t_mseg.

data: itab type it_mseg,

wa type wa_mseg.

select amblnr amatnr

amenge alifnr

b~budat

into table itab

from mseg as a

join mkpf as b

on amblnr = bmblnr

where werks = p_werks and

budat in s_budat.

Cheers,

Abdul Hakim

Read only

Former Member
0 Likes
1,366

Hi,

Just simple one..., change the Types to DATA.

Tables: mseg,mkpf,lfa1,ekko,ekpo,bseg,bkpf.

selection-screen begin of block b1 with frame title text-001.

parameters: p_werks like mseg-werks.

select-options: s_budat for Mkpf-budat.

selection-screen end of block b1.

types:begin of t_mseg,

p_werks type werks_d, "Plant location

mblnr type mblnr, "Number of Material Document

s_budat type budat, "Posting date in document

mtsnr type mtsnr1, "Number of external material slip

maktx type maktx, "Material description

menge type menge_d, "Quantity

lifnr type lifnr, "Vendor Number

name1 type name1_gp, "Name1

name2 type name2_gp, "Name2

telf1 type telf1, "Telephone number

trnam type ztrnam, "Transporter name

glano type zglano, "GR/LR/AWB No

J_1ICSTNO type J_1ICSTNO, "Central Sales Tax Number

J_1ILSTNO type J_1ILSTNO, "Local Sales Tax Number

J_1IEXRN type J_1IEXRN , "Excise Registration Number

end of t_mseg.

*data: begin of it_mseg ,

  • mblnr like mseg-mblnr,

  • budat like mkpf-budat,

  • mtsnr like gohead-mtsnr,

  • maktx like makt-maktx,

  • menge like mseg-menge,

  • lifnr like mseg-lifnr,

  • name1 like lfa1-name1,

  • name2 like lfa1-name2,

  • telf1 like lfa1-telf1,

  • trnam like zmigo_addition-trnam,

  • glano like zmigo_addition-glano,

  • end of it_mseg.

<b>data</b>: it_mseg type standard table of t_mseg,

wa_mseg type t_mseg.

select amblnr amatnr

amenge alifnr

b~budat

into it_mseg

from mseg as a

join mkpf as b

on amblnr = bmblnr

where werks = p_werks and

budat = s_budat.

append wa_MSEG to it_mseg.

endselect.

Regards

vijay

Read only

Former Member
0 Likes
1,366

Hi,

Make the following changes

<b>1st Change</b>

types: it_mseg type standard table of t_mseg,

wa_mseg type t_mseg.

\/

data: it_mseg type table of t_mseg,

wa_mseg type t_mseg.

<b>2nd change</b>

select amblnr amatnr

amenge alifnr

b~budat

into it_mseg

from mseg as a

join mkpf as b

on amblnr = bmblnr

where werks = p_werks and

budat = s_budat.

append wa_MSEG to it_mseg.

endselect.

\/

select amblnr amatnr

amenge alifnr

b~budat

<b>into table it_mseg</b>

from mseg as a

join mkpf as b

on amblnr = bmblnr

where werks = p_werks and

budat = s_budat.

Read only

Former Member
0 Likes
1,366

Hi Amit,

<b>What kind of error is coming to you....?</b>

There is no problem with your types statement.

You can create internal table like this:

data: it_mseg type table of t_mseg with header line,

wa_mseg type t_mseg.

Also you have to assign the selected values to an internal table in the inner join.

Refer this link if you have any doubt regarding inner joins...

http://help.sap.com/saphelp_nw2004s/helpdata/en/fc/eb39c4358411d1829f0000e829fbfe/content.htm

Regards,

SP.

Read only

former_member480923
Active Contributor
0 Likes
1,367

Hi

Just one Modification

Instead of using the following

types: it_mseg type standard table of t_mseg,

use

data: it_mseg type standard table of t_mseg,

Hope this Helps

Anirban

Read only

Former Member
0 Likes
1,366

Hi,

Making the following changes might help your cause :-

1. Instead of 'types' keyword use 'data' in the statement


  types: it_mseg type standard table of t_mseg,
         wa_mseg type t_mseg.

2. In SELECT statement 'table' keyword should follow into.


select a~mblnr a~matnr
a~menge a~lifnr
b~budat
into <b> table</b> it_mseg
from mseg as a
join mkpf as b
on a~mblnr = b~mblnr
where werks = p_werks and
budat = s_budat.
append wa_MSEG to it_mseg.
endselect.

Hope this helps you.

Regards,

Anirban.

Read only

Former Member
0 Likes
1,366

use like this...

Ex Code:

-


types : begin of itab,

matnr like mara-matnr.

end of itab.

<b>Data Itab1 type standard table of Itab with header line.</b>

select Matnr from mara into <b>TABLE ITAB1</b>

from mara

where matnr < '000000000000000010'.

loop at itab1.

write : /, itab1.

end loop.

Read only

Former Member
0 Likes
1,366

You have to use data instead of type

Data :begin of t_mseg,

p_werks type werks_d, "Plant location

mblnr type mblnr, "Number of Material Document

s_budat type budat, "Posting date in document

mtsnr type mtsnr1, "Number of external material slip

maktx type maktx, "Material description

menge type menge_d, "Quantity

lifnr type lifnr, "Vendor Number

name1 type name1_gp, "Name1

name2 type name2_gp, "Name2

telf1 type telf1, "Telephone number

trnam type ztrnam, "Transporter name

glano type zglano, "GR/LR/AWB No

J_1ICSTNO type J_1ICSTNO, "Central Sales Tax Number

J_1ILSTNO type J_1ILSTNO, "Local Sales Tax Number

J_1IEXRN type J_1IEXRN , "Excise Registration Number

end of t_mseg.

Correct code in this way..........

Rewards points if helpful.

Regards

Abhishek

Read only

Former Member
0 Likes
1,366

Hi Amit,

Just copy it.


SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS: p_werks LIKE mseg-werks.
SELECT-OPTIONS: s_budat FOR mkpf-budat.
SELECTION-SCREEN END OF BLOCK b1.

TYPES:BEGIN OF t_mseg,
      mblnr TYPE mseg-mblnr,
      matnr TYPE mara-matnr,
      menge TYPE mseg-menge,
      lifnr TYPE mseg-lifnr,
      budat TYPE mkpf-budat,
      END OF t_mseg.

<b>DATA:  it_mseg TYPE STANDARD TABLE OF t_mseg,
       wa_mseg TYPE t_mseg,
       itab    TYPE STANDARD TABLE OF t_mseg,
       wa      TYPE i_mseg.</b>

SELECT a~mblnr a~matnr
a~menge a~lifnr
b~budat
INTO TABLE itab
FROM mseg AS a
JOIN mkpf AS b
ON a~mblnr = b~mblnr
WHERE werks = p_werks AND
budat IN s_budat.


Regards,

Arun Sambargi.