‎2007 Jun 29 8:13 AM
Hi,
Can I give a field name of an internal table other than the corresponding DB table?
Thanx,
Mohit.
‎2007 Jun 29 10:16 AM
hi mohit,
yes u can define an internal table field other than DB table.
types : begin of ty_mara,
mat type mara-matnr,
end of ty_mara.
types : it_mara type standard table of ty_mara.
hope this may be helpfull.
please reward in case useful...
regards,
prashant
‎2007 Jun 29 8:17 AM
hi
yes u can give ur own fields also in the internal table apart from DB table fields
but u have to populate them explicitly...
like u cant use select <fields> from <dbtable > into table itab..
something like this type...
tables mara.
data : begin of itab occurs 1,
matnr like mara-matnr,
name(20),
end of itab.
select matnr from mara into corresponding fields of table itab.
loop at itab.
itab-name = 'xyz'.
modify itab transporting name .
write : / itab-matnr,
itab-name.
endloop.
*
hope it helps
Message was edited by:
Premalatha G
‎2007 Jun 29 8:22 AM
hi,
u can give but u should create a internal table with TYPES keyword then asign all database fields and your own required fields to find and create a internal table with respect to types.
ex:
types: begin o itab,
matnr like mara-matnr,
ersda like mara-ersda,
ernam like mara-ernam,
num type i,
name type ,
aluri type char,
end of itab.
data: jtab type itab occurs 0 with header line.
\if helpfl reward some points.
with regards,
Suresh.A
‎2007 Jun 29 9:53 AM
Hi,
Yes, you can give field name without corresponding of original tabl, but you should use Corresponding key in syntax.
EXAMPLE:
DATA: BEGIN OF ITAB OCCURS 0,
WAERS LIKE TCURC-WAERS,
ALTWR LIKE TCURS-ALTWR,
END OF ITAB.
SELECT * FROM TCURS INTO CORRESPONDING FIELDS OF TABLE ITAB.
IF USEFULL REWARD POINTS
‎2007 Jun 29 10:09 AM
HI,
YOU CAN GIVE IT NO PROBLEM BUT YOU HAVE TO DECLARE IN THIS MANNER
TYPES : BEGIN OF TY_VBAK,
VBELN TYPE VBELN_VA,
ERDAT TYPE ERDAT,
ERZET TYPE ERZET,
ERNAM TYPE ERNAM,
END OF TY_VBAK.
TYPES : BEGIN OF TY_VBAP,
VBELN TYPE VBELN_VA,
POSNR TYPE POSNR_VA,
MATNR TYPE MATNR,
MATWA TYPE MATWA,
END OF TY_VBAP.
TYPES : BEGIN OF TY_MARA,
MATNR TYPE MATNR,
MTART TYPE MTART,
MBRSH TYPE MBRSH,
MATKL TYPE MATKL,
ANY(4) ,
END OF TY_MARA.
TYPES : TT_VBAK TYPE STANDARD TABLE OF TY_VBAK,
TT_VBAP TYPE STANDARD TABLE OF TY_VBAP,
TT_MARA TYPE STANDARD TABLE OF TY_MARA.
DATA : IT_VBAK TYPE TT_VBAK WITH HEADER LINE,
IT_VBAP TYPE TT_VBAP WITH HEADER LINE,
IT_MARA TYPE TT_MARA WITH HEADER LINE.
‎2007 Jun 29 10:16 AM
hi mohit,
yes u can define an internal table field other than DB table.
types : begin of ty_mara,
mat type mara-matnr,
end of ty_mara.
types : it_mara type standard table of ty_mara.
hope this may be helpfull.
please reward in case useful...
regards,
prashant
‎2007 Jun 29 10:18 AM
Hi mohit,
You can use your own name in internal table.It wont affect DB tables.
But you should use properly.Mostly internal tame will be related to DB table name
For example.
MARA table.
so internal name will be ITAB_MARA or IT_MARA.
before using internal table you have to declare.
example:
DATA : ITAB LIKE MARA OCCURS 0 WITH HEADER LINE.
SELECT * FROM MARA INTO TABLE ITAB_MARA WHERE MATNR = MARA-MATNR.
LOOP AT ITAB1.
.................................................
.................................................
....................................................
ENDLOOP.
.
If its useful reward points.
Thanks
senthil
‎2007 Jun 29 10:23 AM
Hi Mohil,
Wel i would like to add a point...
u can give ur own names for the Internal table fields...but it wil always good if u maintain the same name....
whenever we are writing a program...we should think in others perspective view also ie good programming...since other should also understand ur coding easily ...for this purpose in every project we use a standard notations for coding techniques like..
for select option should start with S_
parameter P_
Internal table GT_
Types TY_
Global var G_
Local var L_
Regards..
Balaji ( reward points if this helps u ..)
‎2007 Jun 29 10:46 AM
HI.
It is depending upon your requirement.
First create Work area with all required field and create internal atble if you want particular fileds.
eg:data: begin of wa.
<required fields>
end of wa.
data:itab like table of wa.
ELSE.
if you want all fields from database table
eg:itab like EKKO with header line.
Reward all helpfull answers.
Regards.
Jay