‎2008 Nov 04 4:48 AM
Hi All,
I have to declare a type like below:
types: BEGIN OF ty_cm_record ,
rectype TYPE c,
compid(3) TYPE c, "Distribution Channel
filler TYPE c VALUE 'C',
count(5) TYPE n, "record count
distro(3) TYPE c, "Second key - Distribution
end of ty_cm_records.
data:it_cm_records type standard table of ty_cm_record.
above i have to declare a default value of filler as 'C' in type declaration .But i am getting error as ' expected after C.
We can do it like below:
types: BEGIN OF ty_cm_record occurs 0,
rectype TYPE c,
compid(3) TYPE c, "Distribution Channel
filler TYPE c VALUE 'C',
count(5) TYPE n, "record count
distro(3) TYPE c, "Second key - Distribution
end of ty_cm_records.
but this type declaration is not permitted in our coding standard
Please sugest the solution.
Thanks
Mohit Khandelwal
‎2008 Nov 04 4:58 AM
Then you have to use a global Constant for Filler and assign it wherever it is used.
CONSTANTS filler TYPE C VALUE 'C'.Regards
Karthik D
‎2008 Nov 04 4:58 AM
Then you have to use a global Constant for Filler and assign it wherever it is used.
CONSTANTS filler TYPE C VALUE 'C'.Regards
Karthik D
‎2008 Nov 04 5:11 AM
hi ,
But how i would assign this feild to fiiler to my internal table once i declared filler as a constant.
Thanks
Mohit
‎2008 Nov 04 6:35 AM
How you are fetching entries into your internal table, if you add record by record you can assign it to the workarea before inserting it into the internal table, if you are fetching records using select statement, write a loop after it to set all filler to the value of filler constant.
Regards
Karthik D
‎2008 Nov 04 4:58 AM
Hi,
DATA: BEGIN OF ty_cm_records OCCURS 0,
rectype TYPE c,
compid(3) TYPE c, "Distribution Channel
filler TYPE c VALUE 'C',
count(5) TYPE n, "record count
distro(3) TYPE c, "Second key - Distribution
END OF ty_cm_records.
as you donot want to use this...better declare filler as constant...like the above post...
‎2008 Nov 04 5:09 AM
hi,
thanks for your sugestion.but this field filler should be present in my table ty_cm_reocrds.
Thanks
Mohit
‎2008 Nov 04 5:13 AM
Hi,
have u seen what happens when u use OCCURS 0 and why u cannot use 'VALUES' in Types....
types: BEGIN OF ty_cm_record occurs 0,
rectype TYPE c,
compid(3) TYPE c, "Distribution Channel
filler TYPE c VALUE 'C',
count(5) TYPE n, "record count
distro(3) TYPE c, "Second key - Distribution
end of ty_cm_records.
This is what is getting populated in its *header* part
RECTYPE
COMPID
FILLER C
COUNT 00000
DISTRO
and u cannot use values in Types because it is a type...it doesnot contain any data....
and if u use
data:it_cm_records type standard table of ty_cm_record.
there is no header part....
so define a header line with the initial value...
DATA: BEGIN OF ty_cm_record,
rectype TYPE c,
compid(3) TYPE c,
filler TYPE c VALUE 'C',
count(5) TYPE n,
distro(3) TYPE c,
END OF ty_cm_record.
DATA : it_cm_records LIKE STANDARD TABLE OF ty_cm_record.
see both the ty_cm_record. and it_cm_records..
‎2008 Nov 04 5:30 AM
Hi,
I think we can not assign values in type declarations. you can declare one work area and assign the values.
Try like this:
types: BEGIN OF ty_cm_record ,
rectype TYPE c,
compid(3) TYPE c,
filler TYPE C,
count(5) TYPE n, "record count
distro(3) TYPE c, "Second key - Distribution
end of ty_cm_record.
data:it_cm_records type ty_cm_record.
it_cm_records-filler = 'C'.
Regards,
Bhaskar
‎2008 Nov 04 6:20 AM
TYPES: BEGIN OF TY_CM_RECORD,
RECTYPE TYPE C,
COMPID(3) TYPE C, "Distribution Channel
FILLER TYPE C,
COUNT(5) TYPE N, "record count
DISTRO(3) TYPE C, "Second key - Distribution
END OF TY_CM_RECORD.
DATA:IT_CM_RECORDS TYPE STANDARD TABLE OF TY_CM_RECORD WITH HEADER LINE.
IT_CM_RECORDS-FILLER = 'C'.