cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with TYPES

Former Member
0 Kudos

Hi.

I have a problem with TYPES.

I have a parameter with this defintion

ls_rnbadi_ncir TYPE rnbadi_ncir.

I want to modifify one of your fields, this field is kostr, but I can´t acces to it.

How can I access to it???

Thank you very much.

I am in the ABAP Objects Context.

Accepted Solutions (0)

Answers (6)

Answers (6)

Former Member
0 Kudos

Hi Jorge,

Always good to meet an IS-H Collegue!

Cheers,

Ofer

Former Member
0 Kudos

Thak You ofr your help , but I have found the solution!!!

Former Member
0 Kudos

I need to access the data of the kostr field , how can i make it??

Former Member
0 Kudos

Hi

I don't understand what you really want to do:

Do you want to change the defintion of the structure or a value of a field of the structure?

If you want to change the value you can only if it's an exporting parameter, so let's know the BADI you're using.

Max

Former Member
0 Kudos

u cannot change SAP standard types , for that u need access key , copy the type into ur ztype and modify and use it

Former Member
0 Kudos

Hai Jorge

go through the following Document

TYPES

Variants

1. TYPES typ.

2. TYPES typ(len).

3. TYPES: BEGIN OF rectyp,

...

END OF rectyp.

Effect

The TYPES statement introduces user-defined data types . As with standard data types, you can use them when creating data objects and when assigning types to formal parameters and field symbols. User-defined data types are an essential component of the ABAP/4 type concept .

Variant 1

TYPES f.

Additions

1. ... TYPE typ1

2. ... LIKE f

3. ... TYPE typ1 OCCURS n

4. ... LIKE f OCCURS n

5. ... TYPE LINE OF itabtyp

6. ... LIKE LINE OF itab

7. ... DECIMALS n

Effect

Creates a new type. If the TYPE addition is not used, the new type points to the standard type C .

The type name typ can be up to 30 characters long. Apart from the special characters '(', ')', '+', '.', ',', ':', '-', '<' and '>', you can use any characters. Numbers are allowed, but the name cannot consist of numbers alone.

Recommendations for type names:

Always use a letter as the first character.

Use the underscore as the link in multiple word names (e.g. NEW_PRODUCT ).

Addition 1

... TYPE typ1

Effect

Defines the new type with the type typ1 . typ1 can be one of the predefined types specified below or a type you define yourself with TYPES .

The length (SL) of the type typ is the same as the type typ1 .

Type Description Std len. Initial value

C Text (character) 1 Blank

N Numeric text 1 '00...0'

D Date (YYYYMMDD) 8 '00000000'

T Time (HHMMSS) 6 '000000'

X Hexadecimal 1 X'00'

I Whole number (integer) 4 0

P Packed number 8 0

F Floating point number 8 '0.0'

Example

TYPES NUMBER TYPE I.

This defines the type NUMBER NUMBER with the type I . It can then be used in the program.

Notes

The data type I is the whole number type for the hardware you are using. Its value range is -2*31 to 2*31-1 (-2.147.483.648 to 2.147.483.647).

While type P is used for money amount fields, you should use type I for number fields, index fields, position specifications, etc.

Apart from zero, type F allows you to display positive and negative numbers in the range from 1E-307 to 1E+307 with 15 decimal places. (The ABAP/4 processor uses the floating point operations of the relevant hardware and does not attempt to standardize them.) Floating point literals must be enclosed in quotation marks. The standard output length is 22.

Input in type F fields can be formatted differently:

Decimal number with or without sign, with or without decimal point.

In the form E, where the mantissa is a decimal number and the exponent can be specified with or without a sign. (Examples of floating point literals: '1', '-12.34567', '-765E-04', '1234E5', '12E34', '+12.3E-4', '1E160').

Floating point arithmetic is fast on our hardware platforms. It is ideal when you require a large value range and can take rounding errors into account when making calculations. Such rounding errors can occur when converting from external (decimal) format to internal format (base 2 or 16) or vice-versa (see ABAP/4 number types ).

Addition 2

... LIKE f

Effect

Defines the type typ with the type of the field f . f may be a database field or an already defined internal field.

Example

TYPES TABLE_INDEX_TYP LIKE SY-TABIX.

The type TABLE_INDEX_TYP now points to the type of the field SY-TABIX (index for internal tables).

Note

This addition is useful in a number of cases, since any field type changes are automatically known to the program. Also, any unnecessary and unwanted conversions are not performed.

Addition 3

... TYPE typ1 OCCURS n

Effect

Defines the type of an internal table without a header line. An internal table without a header line consists of any number of table lines that have the same structure as that specified by TYPE .

You fill and process an internal table with statements such as APPEND , READ TABLE , LOOP and SORT .

The OCCURS parameter n specifies how many table lines of storage is required. This storage reservation process does not happen until the first line is inserted in the table. The value n of the OCCURS specification has no effect on type checking, i.e. data objects which have types with different OCCURS specifications are type-compatible.

Example

TYPES: TAB_TYPE TYPE I OCCURS 20.

DATA: TAB TYPE TAB_TYPE,

TAB_WA TYPE I.

TAB_WA = 1.

APPEND TAB_WA TO TAB.

TAB_WA = 2.

APPEND TAB_WA TO TAB.

The internal table TAB now consists of two table entries.

Addition 4

... LIKE f OCCURS n

Effect

Defines the type of an internal table without a header line. This table consists of any number of table lines which have the structure specified by the data object f . Processing is the same as for addition 3.

Example

DATA: BEGIN OF PERSON,

NAME(20),

AGE TYPE I,

END OF PERSON.

TYPES TYPE_PERSONS LIKE PERSON OCCURS 20.

DATA PERSONS TYPE TYPE_PERSONS.

PERSON-NAME = 'Michael'.

PERSON-AGE = 25.

APPEND PERSON TO PERSONS.

PERSON-NAME = 'Gabriela'.

PERSON-AGE = 22.

APPEND PERSON TO PERSONS.

The internal table PERSONS now consists of two table entries.

Addition 5

... TYPE LINE OF itabtyp

Effect

The specified type itabtyp must be the type of an internal table with or without a header line. The statement creates a type corresponding to the line type of the specified table type.

Example

TYPES TAB_TYP TYPE I OCCURS 10.

TYPES MY_TYPE TYPE LINE OF TAB_TYP.

The type MY_TYPE now has the same attributes as a line of the table type TAB_TYP and is thus type I .

Addition 6

... LIKE LINE OF itab

Effect

The data object itab must be an internal table with or without a header line. The statement defines a type which corresponds to the line type of the specified table.

Example

DATA TAB TYPE I OCCURS 10.

TYPES MY_TYPE LIKE LINE OF TAB.

The type MY_TYPE now has the same attributes as the line type of the table TAB and thus has the type I .

Addition 7

... DECIMALS n

Effect

This addition only makes sense with the field type P . When making calculations and outputting data, a field of this type has n decimal places. n must be a value between 0 and 14.

Normally, the attribute for fixed point arithmetic is set with newly created programms. If you switch this attribute off, the DECIMALS -specification is taken into account on output, but not when making calculations. In this case, the programmer must take care that the decimal point is in the right place by multiplying or dividing (COMPUTE ) by the appropriate power of ten.

When making calculations, you should always have fixed point arithmetic switched on. Then, even intermediate results (division!) are calculated with the greatest possible accuracy (31 decimal places).

To decide whether the fixed point type P or the floating point type F is more suitable, see also "ABAP/4 number types ".

Variant 2

TYPES typ(len).

Additions

Similar to variant 1

Effect

Creates the type typ with the length len .

This variant should only be used with the types C , N , P and X . Other types can only be created in the standard length (see table under effect of variant 1).

The permitted lengths depend on the type being pointed to:

Type Permitted lengths

C 1 - 65535

N 1 - 65535

P 1 - 16

X 1 - 65535

Note

For each byte, you can display one character, two decimal digits or two hexadecimal digits. With P fields, one place is reserved for the leading sign, so that a P field of the length 3 can contain 5 digits, while an X field of the length 3 can contain 6 digits. Both have an output length of 6.

Variant 3

TYPES: BEGIN OF rectyp,

...

END OF rectyp.

Effect

Defines the field string type rectyp by grouping together all fields of the type rectyp defined between " BEGIN OF rectyp " and " END OF rectyp ". Each name is prefixed by " rectyp- ".

Example

TYPES: BEGIN OF PERSON,

NAME(20) TYPE C,

AGE TYPE I,

END OF PERSON.

Also Check with the Parameters Documentation

PARAMETERS p

Additions

1. ... DEFAULT f

2. ... TYPE typ

3. ... DECIMALS

4. ... LIKE g

5. ... MEMORY ID pid

6. ... MATCHCODE OBJECT mobj

7. ... MODIF ID key

8. ... NO-DISPLAY

9. ... LOWER CASE

10. ... OBLIGATORY

11. ... AS CHECKBOX

12 ... RADIOBUTTON GROUP radi

13. ... FOR TABLE dbtab

14. ... AS MATCHCODE STRUCTURE

15. ... VALUE-REQUEST

16. ... HELP-REQUEST

Effect

Definition of report parameters.

This statement only makes sense in report programs, i.e. in programs defined as type '1' in the attributes. You execute report programs with the SUBMIT statement. When this takes place, the parameters and selection options (SELECT-OPTIONS ) specified in the report program shape the interface which determines what the user sees on the selection screen. These parameters and selection options are then presented to the user who can enter values (see the addition NO-DISPLAY or SUBMIT without the addition VIA SELECTION-SCREEN ).

Creates internal fields like the DATA statement.

By making the appropriate entry in the attributes, you can assign a report to a logical database ldb . In this case, both the logical database ldb and the report can define parameters (and selection options). You define the database-specific parameters (i.e. those belonging to the logical database) in an ABAP/4 INCLUDE program DBldbSEL (in the logical database maintenance transaction). Since the system then integrates this INCLUDE program in the logical database access program SAPDBldb and (partially) in the report, the database-specific parameters (and selection options) are available to both.

The ("report-specific") parameters defined in the report are known only in the report (not in the SAPDBldb ).

Some additions of PARAMETERS are allowed only in the DBldbSEL .

Example

PARAMETERS: SUM(1).

Notes

The name of a parameter can be up to 8 characters long.

By selecting Goto -> Text elements and then choosing Selection texts followed by Display , you can enter a description for each parameter; this is then displayed on the selection screen. You define the report-specific parameter texts with the text elements of the report and the database-specific parameter texts with the text elements of the database program SAPDBldb .

Addition 1

... DEFAULT f

Effect

Assigns the default value f to the parameter.

Note

You must specify the default value f in internal format, e.g. PARAMETERS DATE LIKE SY-DATUM DEFAULT '19931224' , not ... DEFAULT '24.12.1993' .

Addition 2

... TYPE typ

Effect

Assigns the type typ to the internal field.

Example

PARAMETERS: NUMBER(4) TYPE P DEFAULT '999'.

Addition 3

... DECIMALS dec

Effect

Assigns dec decimal places to the internal field. dec must be numeric.

Note

You can only use the addition DECIMALS dec with the addition TYPE P , i.e. it is only allowed with parameters of type P .

Example

PARAMETERS: NUMBER (4) TYPE P DECIMALS 2 DEFAULT '123.45'.

Addition 4

... LIKE g

Effect

Creates the field p with the same attributes as the field g which is already defined. g can be either a database field or an existing internal field.

Note

You cannot use the addition ... LIKE g with the addition ... TYPE typ . No explicit length may be specified for the parameter (for example, a statement such as PARAMETERS p(len) LIKE g is not allowed).

Example

PARAMETERS PROGRAM LIKE SY-REPID.

Note

If g is an ABAP/4 Dictionary field of the type CHAR , length 1 and default values 'X' and ' ' (according to the relevant domain), the parameter is always displayed as a checkbox on the selection screen (see also AS CHECKBOX ).

Field attributes on the selection screen:

The input/output field which appears on the selection screen for the parameter has the attributes of the field g specified after LIKE . These include type, length or - with ABAP/4 Dictionary fields - conversion exit .

If g is an ABAP/4 Dictionary field, the selection screen is automatically regenerated after most field attribute changes. An excception to this rule are the attributes "Check table" and "Fixed values". If these change, you must generate the program in the ABAP/4 Development Workbench. This also generates the selection screen.

The maximum permitted length of a parameter on the selection screen is 45 (scrollable up to length 132). If you have defined it longer than this (either explicitly with p(200) or implicitly with LIKE ), the parameter is truncated on the selection screen after the 132nd character. However, you can use SUBMIT to pass longer parameters to a report (particularly if these are not displayed on the selection screen at all because of the addition NO-DISPLAY ).

Addition 5

... MEMORY ID pid

Effect

On the selection screen, assigns the memory ID pid to the parameter, i.e. when you execute the report, the selection screen displays the last value which the user entered in a field with the memory ID pid .

Note

The memory ID must be a constant, i.e. a value specified without quotation marks, and can be up to 3 characters long.

Addition 6

... MATCHCODE OBJECT mobj

Effect

On the selection screen, assigns the matchcode object mobj to the parameter.

Note

The name of the matchcode object must be a constant, i.e. a value specified without quotation marks, and can be up to 4 characters long.

Addition 7

... MODIF ID key

Effect

The screen fields contain the specified modification group ( SCREEN-GROUP1 ) which you can use for screen modifications (e.g. set to "not ready for input") under AT SELECTION-SCREEN .

Note

The name of the modification group must be a constant, i.e. a value specified without quotation marks, and can be up to 3 characters long.

Example

PARAMETERS CHARLY MODIF ID ABC.

...

AT SELECTION-SCREEN OUTPUT.

LOOP AT SCREEN.

IF SCREEN-GROUP1 = 'ABC'.

SCREEN-INPUT = '0'.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

...

Effect

The parameter is not ready for input on the selection screen.

Addition 8

... NO-DISPLAY

Effect

Does not display the parameter on the selection screen. With "normal" parameters, the associated data object is created and the parameter can be passed when SUBMIT is executed.

These parameters are the part of the report interface not presented to the user on the selection screen. You can set the parameter values either internally (with the routine INIT in the SAPDBldb or at INITIALIZATION ) or pass them when SUBMIT is executed. These parameters are also stored along with the variants.

If, under certain circumstances (e.g. because of the values of other parameters or due to the selection options ), you want to present the parameter to the user for input, you can do this in the PAI modlue of the database program SAPDBldb (for database-specific parameters) or under AT SELECTION-SCREEN (for report-specific parameters) by calling a function module (CALL FUNCTION ) or your own screen (CALL SCREEN < /> ).

Note

Since the parameter is not generated on the selection screen, the NO-DISPLAY parameters do not allow you to use any of the additions concerning the display and handling of parameters on the selection screen.

Addition 9

... LOWER CASE

Effect

The parameter is not case-sensitive (i.e. allows both upper and lower case).

Addition 10

... OBLIGATORY

Effect

Makes an entry on the selection screen compulsory.

Addition 11

... AS CHECKBOX

Effect

Displays the parameter as a checkbox on the selection screen.

Since you are not allowed to specify type or length when defining this parameter, it always has the type C and the length 1 as default values.

The checkbox is displayed on the left and the associated text on its right. To define any order other than this, use the SELECTION-SCREEN statement.

Note

If LIKE refers to an ABAP/4 Dictionary field, you cannot use the addition AS CHECKBOX . If the ABAP/4 Dictionary field has the type CHAR , a length of 1 and the fixed values 'X' and ' ' (according to the relevant domain), the parameter is always displayed as a checkbox on the selection screen.

Addition 12

... RADIOBUTTON GROUP radi

Effect

Displays the parameter on the selection screen as a radio button (selection field). All parameters assigned in this way to the same group radi (which can be up to 4 characters long) form a group of radio buttons on the selection screen, i.e. if the user presses one of these buttons, the others are set to "not pressed".

When you define one of these parameters, you are not allowed to make type or length specifications. However, you can use LIKE to point to a field of length 1 and type C .

The addition has no effect on the ordering of the parameter (as is the case with the addition AS CHECKBOX ). You can make changes to the order with the SELECTION-SCREEN .

Note

A RADIOBUTTON group must contain at least two parameters. One of these can have a DEFAULT addition and the DEFAULT value must be 'X' .

In the database INCLUDE DBldbSEL , a RADIOBUTTON parameter must include the addition FOR TABLE dbtab just like any other parameter. All parameters in a group must belong to the same table dbtab .

A group name radi used in the DBldbSEL cannot be used in the report.

In contrast to "normal" parameters, the event AT SELECTION-SCREEN ON p is not executed (it is not even allowed syntactically). Instead, the event AT SELECTION-SCREEN ON RADIOBUTTON GROUP radi exists for the entire group. If an E message or a W message is output, all radio buttons in the group are ready for input.

Addition 13

... FOR TABLE dbtab

Effect

Assigns the database-specific parameter p to the table dbtab .

This addition only makes sense in a logical database access program.

With database-specific parameters, you need this addition to ensure that the selection screen for a report contains only database-specific parameters which belong to a table from the currently active report.

Addition 14

... AS MATCHCODE STRUCTURE

Effect

Creates the database-specific parameter p as a field string according to the Dictionary structure MCPARAMS with the fields MCID (matchcode ID ) and STRING (search string ).

Used for data selection through matchcode entry.

On the selection screen, both sub-fields are displayed in a box with the text "Matchcode selection".

You can get a list of possible entries for the matchcode ID and the search string by pressing F4 . If you choose a matchcode ID and press F4 in the field "Search string", you see a dialog box where you can enter a search criterion for each field of the matchcode ID. The system interprets what you enter generically for each sub-field.

Note

The addition AS MATCHCODE STRUCTURE only makes sense in a logical database access program and must therefore be used together with the addition FOR TABLE . It can also be combined with the addition MODIF ID , but not with any other additions. The matchcode object to which the matchcode ID and the search string refer is determined when you define the logical database.

Example

Input on the selection screen:

Matchcode ID: Customers Search string: Daniel

The effect of this is to select all customers whose names begin with "Daniel".

Note

Performance

Matchcode selection can improve program performance considerably. This is because specifying a search string often describes the required set of data records more accurately than the key fields of the table. For example, it is easier to select by name ("Daniel") than by customer number ("000043010") and far fewer records are read from the database.

Note

If a logical database (e.g. ldb ) contains a parameter p defined with AS MATCHCODE STRUCTURE , the system always creates an internal table ldb_MC which includes all the key fields of the selected records. The structure of ldb_MC is determined by the matchcode object and generated automatically. In the maintenance transaction for logical databases, the structure is displayed as a comment in the database program.

Example

Matchcode object for table T1 with key field T1-K1 . The table ldb_MC then has the following structure:

DATA: BEGIN OF ldb_MC OCCURS 100,

T1_K1 LIKE T1-K1,

END OF ldb_MC.

Note

If the user has entered values in the matchcode parameter fields, the program reads the selected data from the matchcode table after START-OF-SELECTION and makes it available to the logical database program in the internal table ldb_MC . Then, the database program processes the records in the subroutine PUT_ldb_MATCHCODE and, with the help of PUT , triggers the appropriate GET events in the report. Subsequent processing is exactly the same as that for data selection direct from the database.

Example

FORM PUT_ldb_MATCHCODE.

SELECT * FROM T1

WHERE K1 = ldb_MC-T1_K1

FOR ALL ENTRIES IN ldb_MC.

PUT T1.

ENDSELECT.

ENDFORM.

Note

In matchcode selection, the system flags all fields in the internal table MC_FIELDS which are filled with values by the matchcode (the field name is in MC_FIELDS-FIELDNAME and the flag is in MC_FIELDS-SUPPLIED ).

Example

A field F0 is supplied with a value by the matchcode if the following condition is satisfied:

IF MC_FIELDS-FIELDNAME EQ 'F0'

AND MC_FIELDS-SUPPLIED NE SPACE.

Note

Further documentation:

In the maintenance transaction for logical databases, select Help -> Extended help

In the editor: logical databases ( LDB )

Addition 15

... VALUE-REQUEST

Effect

This addition is only allowed for database-specific parameters in the INCLUDE DBldbSEL . It permits self-programmed value help (for report-specific parameters, this is achieved by specifying the event key word AT SELECTION-SCREEN ON VALUE-REQUEST FOR ... ). The addition has the following effect:

On the selection screen, the parameter has a button for requesting possible entries. When the user presses this button or F4 , this starts the FORM routine p_VAL in the database access program SAPDBldb (if it exists). Then - even if the parameter with LIKE points to a Dictionary field - this FORM routine is processed rather than displaying the check table or the fixed values of the Dictionary field. You can also branch from the routine p_VAL to a function module which offers a selection list of possible values. At the end of the FORM routine, the contents of the field p are copied to the appropriate input/output field.

Example

  • INCLUDE DBXYZSEL

...

PARAMETERS PL_TYPE LIKE SAPLANE-PLANETYPE VALUE-REQUEST.

...

REPORT SAPDBXYZ DEFINING DATABASE XYZ.

...

TABLES SAPLANE.

...

FORM PL_TYPE_VAL.

...

CALL FUNCTION ...

...

ENDFORM.

Addition 16

... HELP-REQUEST

Effect

Like VALUE-REQUEST , this addition is only allowed for database-specific parameters in the INCLUDE DBldbSEL . It permits self-programmed value help (for report-specific parameters, this is achieved by specifying the event key word AT SELECTION-SCREEN ON VALUE-REQUEST FOR ... ). When the user presses F1 , this starts the FORM routine p_HLP in the database access program SAPDBldb (if it exists). Then - even if the parameter with LIKE points to a Dictionary field - this FORM routine is processed rather than displaying the data element documentation of the Dictionary field. You can also branch from the routine p_HLP to a function module which displays its own documentation.

Example

  • INCLUDE DBXYZSEL

...

PARAMETERS PL_TYPE LIKE SAPLANE-PLANETYPE HELP-REQUEST.

...

REPORT SAPDBXYZ DEFINING DATABASE XYZ.

...

TABLES SAPLANE.

...

FORM PL_TYPE_HLP.

...

CALL FUNCTION ...

...

ENDFORM.

Thanks & Regards

Sreenivasulu P

Message was edited by: Sreenivasulu Ponnadi

sbhutani1
Contributor
0 Kudos

Hi jorge,

You cant change SAP standard without any access key so You can copy rnbadi_ncir and then change it according to your need and then assign the changed one to is_rnbadi_ncir.

Regards

Sumit Bhutani