Field length in internal table
hi,
how to selt field length in internal table?.
i have created on report the report out puts down load to using download function .
the out format is:
op1 op2 op3 op4
1 3 4
i want
op1 op2 op3 op4
1 3 4
how to set this please give sample code.
HI,
Give internal table like this.
DATA: BEGIN OF itab OCCURS 100,
op1(04),
op2(04),
op3(04),
op4(04),
END OF itab.
So it will allocate space between 1, 3 and 4.
Reward if it useful.
Thanks.
Similar Messages
-
Maximum record length in internal table?
Is there a maximum record length in an internal table? Please note: My question is NOT related to table space. I'm referring only to the length of an individual record (A.K.A. row length).
I am using a work area to insert data into an internal table. Both the work area and internal table are defined by the same structure.
The structure has a total length of 672 bytes. For the sake of this discussion I'll point out that at the end of the structure, bytes 669, 670, 671, and 672 are four separate fields of 1 character each.
When viewing the work area record in the debugger I'm seeing all the fields and all the values. When viewing the internal table in the debugger after a record is inserted, the internal table ends with the field defined at Byte 670. The internal table does not include the two fields defined at Bytes 671 and 672.
Am I to assume from the above explanation that the length of a record ( A.K.A. row) in an internal table cannot exceed 670 bytes?
Thank you.Manish,
False alarm! While, technically, you didn't answer my question, your request for code ended up helping me answer my own question.
To provide you with some code I wrote a simple test program using the record layout referred to above, with a DO loop to put some records into the internal table, followed by a LOOP AT, with accompanying WRITE statements to display the contents of the internal table and demonstrate that the last two fields weren't being stored.
However, when I ran the test program, the last two fields were being displayed.
It was at that point, when stepping through the debugger that I noticed the scroll arrows above the last column of my internal table that allowed me to scroll to the right and see my final two fields.
Apparently, because of the large number of fields in my internal table I had reached the default display length of the debugger. While I was obviously aware of the scroll bar found at the bottom of the display, I had never worked with an internal table of that width in the past and hadn't even noticed the scroll arrows above the last column before.
Thanks for taking the time to respond helping me get to the solution. -
How to increase the length of internal table dynamically
How to increase the length of internal table dynamically depending on the number of fields fetched into the internal table ?
The requirement code :
types: begin of t_data,
form like zscr_data_hdr-form,
werks like zscr_data_hdr-werks,
matnr like zscr_data_hdr-matnr,
verid like zscr_data_hdr-verid,
lot like zscr_data_hdr-lot,
lot_qty like zscr_data_hdr-lot_qty,
udate like zscr_data_hdr-udate,
utime like zscr_data_hdr-utime,
zuser like zscr_data_hdr-zuser,
processed like zscr_data_hdr-processed,
defect like zscr_defect_data-defect,
vornr like zscr_route_data-vornr,
fld1 like zscr_defect_data-defect_val,
fld2 like zscr_defect_data-defect_val,
fld3 like zscr_defect_data-defect_val,
fld4 like zscr_defect_data-defect_val,
fld5 like zscr_defect_data-defect_val,
fld6 like zscr_defect_data-defect_val,
fld7 like zscr_defect_data-defect_val,
fld8 like zscr_defect_data-defect_val,
fld9 like zscr_defect_data-defect_val,
fld10 like zscr_defect_data-defect_val,
fld11 like zscr_defect_data-defect_val,
fld12 like zscr_defect_data-defect_val,
fld13 like zscr_defect_data-defect_val,
fld14 like zscr_defect_data-defect_val,
fld15 like zscr_defect_data-defect_val,
fld16 like zscr_defect_data-defect_val,
fld17 like zscr_defect_data-defect_val,
fld18 like zscr_defect_data-defect_val,
fld19 like zscr_defect_data-defect_val,
fld20 like zscr_defect_data-defect_val,
fld21 like zscr_defect_data-defect_val,
fld22 like zscr_defect_data-defect_val,
fld23 like zscr_defect_data-defect_val,
fld24 like zscr_defect_data-defect_val,
fld25 like zscr_defect_data-defect_val,
fld26 like zscr_defect_data-defect_val,
fld27 like zscr_defect_data-defect_val,
fld28 like zscr_defect_data-defect_val,
fld29 like zscr_defect_data-defect_val,
fld30 like zscr_defect_data-defect_val,
fld31 like zscr_defect_data-defect_val,
fld32 like zscr_defect_data-defect_val,
fld33 like zscr_defect_data-defect_val,
fld34 like zscr_defect_data-defect_val,
fld35 like zscr_defect_data-defect_val,
fld36 like zscr_defect_data-defect_val,
fld37 like zscr_defect_data-defect_val,
fld38 like zscr_defect_data-defect_val,
fld39 like zscr_defect_data-defect_val,
fld40 like zscr_defect_data-defect_val,
fld41 like zscr_defect_data-defect_val,
fld42 like zscr_defect_data-defect_val,
fld43 like zscr_defect_data-defect_val,
fld44 like zscr_defect_data-defect_val,
fld45 like zscr_defect_data-defect_val,
fld46 like zscr_defect_data-defect_val,
fld47 like zscr_defect_data-defect_val,
fld48 like zscr_defect_data-defect_val,
fld49 like zscr_defect_data-defect_val,
fld50 like zscr_defect_data-defect_val,
fld51 like zscr_defect_data-defect_val,
fld52 like zscr_defect_data-defect_val,
fld53 like zscr_defect_data-defect_val,
fld54 like zscr_defect_data-defect_val,
fld55 like zscr_defect_data-defect_val,
fld56 like zscr_defect_data-defect_val,
fld57 like zscr_defect_data-defect_val,
fld58 like zscr_defect_data-defect_val,
fld59 like zscr_defect_data-defect_val,
fld60 like zscr_defect_data-defect_val,
fld61 like zscr_defect_data-defect_val,
fld62 like zscr_defect_data-defect_val,
fld63 like zscr_defect_data-defect_val,
fld64 like zscr_defect_data-defect_val,
fld65 like zscr_defect_data-defect_val,
fld66 like zscr_defect_data-defect_val,
fld67 like zscr_defect_data-defect_val,
fld68 like zscr_defect_data-defect_val,
fld69 like zscr_defect_data-defect_val,
fld70 like zscr_defect_data-defect_val,
fld71 like zscr_defect_data-defect_val,
fld72 like zscr_defect_data-defect_val,
fld73 like zscr_defect_data-defect_val,
fld74 like zscr_defect_data-defect_val,
fld75 like zscr_defect_data-defect_val,
fld76 like zscr_defect_data-defect_val,
fld77 like zscr_defect_data-defect_val,
fld78 like zscr_defect_data-defect_val,
fld79 like zscr_defect_data-defect_val,
fld80 like zscr_defect_data-defect_val,
fld81 like zscr_defect_data-defect_val,
fld82 like zscr_defect_data-defect_val,
fld83 like zscr_defect_data-defect_val,
fld84 like zscr_defect_data-defect_val,
fld85 like zscr_defect_data-defect_val,
fld86 like zscr_defect_data-defect_val,
fld87 like zscr_defect_data-defect_val,
fld88 like zscr_defect_data-defect_val,
fld89 like zscr_defect_data-defect_val,
fld90 like zscr_defect_data-defect_val,
fld91 like zscr_defect_data-defect_val,
fld92 like zscr_defect_data-defect_val,
fld93 like zscr_defect_data-defect_val,
fld94 like zscr_defect_data-defect_val,
fld95 like zscr_defect_data-defect_val,
fld96 like zscr_defect_data-defect_val,
fld97 like zscr_defect_data-defect_val,
fld98 like zscr_defect_data-defect_val,
fld99 like zscr_defect_data-defect_val,
fld100 like zscr_defect_data-defect_val,
fld101 like zscr_defect_data-defect_val,
fld102 like zscr_defect_data-defect_val,
fld103 like zscr_defect_data-defect_val,
fld104 like zscr_defect_data-defect_val,
fld105 like zscr_defect_data-defect_val,
fld106 like zscr_defect_data-defect_val,
fld107 like zscr_defect_data-defect_val,
fld108 like zscr_defect_data-defect_val,
fld109 like zscr_defect_data-defect_val,
fld110 like zscr_defect_data-defect_val,
fld111 like zscr_defect_data-defect_val,
fld112 like zscr_defect_data-defect_val,
fld113 like zscr_defect_data-defect_val,
fld114 like zscr_defect_data-defect_val,
fld115 like zscr_defect_data-defect_val,
fld116 like zscr_defect_data-defect_val,
fld117 like zscr_defect_data-defect_val,
fld118 like zscr_defect_data-defect_val,
fld119 like zscr_defect_data-defect_val,
fld120 like zscr_defect_data-defect_val,
fld121 like zscr_defect_data-defect_val,
fld122 like zscr_defect_data-defect_val,
fld123 like zscr_defect_data-defect_val,
fld124 like zscr_defect_data-defect_val,
fld125 like zscr_defect_data-defect_val,
fld126 like zscr_defect_data-defect_val,
fld127 like zscr_defect_data-defect_val,
fld128 like zscr_defect_data-defect_val,
fld129 like zscr_defect_data-defect_val,
fld130 like zscr_defect_data-defect_val,
fld131 like zscr_defect_data-defect_val,
fld132 like zscr_defect_data-defect_val,
fld133 like zscr_defect_data-defect_val,
fld134 like zscr_defect_data-defect_val,
fld135 like zscr_defect_data-defect_val,
dayst like zscr_data_hdr-dayst,
end of t_data.
In this fld1 to fld135 are defined in internal table.
But if the number of fields are more than 135 then the program is going to short dump.
Some times fld1 to fid170 or more fields will be there in my internal table.
Please suggest me how to make my requirement dynamic and display this data fetched into this internal table onto a .XLS file in the presentation server ?Hi
You can try to use the type string:
form like zscr_data_hdr-form,
werks like zscr_data_hdr-werks,
matnr like zscr_data_hdr-matnr,
verid like zscr_data_hdr-verid,
lot like zscr_data_hdr-lot,
lot_qty like zscr_data_hdr-lot_qty,
udate like zscr_data_hdr-udate,
utime like zscr_data_hdr-utime,
zuser like zscr_data_hdr-zuser,
processed like zscr_data_hdr-processed,
defect like zscr_defect_data-defect,
vornr like zscr_route_data-vornr,
fieldxx type string,
dayst like zscr_data_hdr-dayst,
end of t_data.
So you can save you informations of every fld<n> concatenating their values into fieldxx.
Max -
How to increase field size in Internal table
Hi friends,
I want to concatenate around 20 fields in one internal table field,
i declared the destination filed as character, now i am able to get around 12 to 13 fileds only , how to increase the length of this field to include all fields ?
or how can i do this ? can any body help me ?
I concatenate this to create a file which will be send as email attachment.
its very urgent issue, kindly help me to resolve as early as possible.
Thanks in advance.
JosephHi,
Use the string data type..
Example
DATA: IT_STRING TYPE STRING OCCURS 0 WITH HEADER LINE.
DATA: BEGIN OF WA,
MATNR(18),
WERKS(4),
VBELN(10),
END OF WA.
CONCATENATE WA-MATNR WA-WERKS WA-VBELN INTO IT_STRING.
APPEND IT_STRING.
Thanks,
Naren -
To Find the type of field in the internal table.
I have internal table i_tab.
TYPES : BEGIN OF t_makt,
matnr TYPE matnr,
maktx TYPE maktx,
qty type mseg-menge,
show type char01,
END OF t_makt.
DATA : i_tab TYPE t_makt OCCURS 0 WITH HEADER LINE.
I want to know the type of the field of the i_tab at some stage in the program.
is there any piece of code or FM available to find the TYPE of the field of the internal table.Check out the following code
TYPES:
BEGIN OF my_struct,
comp_a type i,
comp_b type f,
END OF my_struct.
DATA:
my_data TYPE my_struct,
descr_ref TYPE ref to cl_abap_structdescr.
FIELD-SYMBOLS:
<comp_wa> TYPE abap_compdescr.
START-OF-SELECTION.
descr_ref ?= cl_abap_typedescr=>describe_by_data( my_data ).
WRITE: / 'Typename :', descr_ref->absolute_name.
WRITE: / 'Kind :', descr_ref->type_kind.
WRITE: / 'Length :', descr_ref->length.
WRITE: / 'Decimals :', descr_ref->decimals.
WRITE: / 'Struct Kind :', descr_ref->struct_kind.
WRITE: / 'Components'.
WRITE: / 'Name Kind Length Decimals'.
LOOP AT descr_ref->components ASSIGNING <comp_wa>.
WRITE: / <comp_wa>-name, <comp_wa>-type_kind,
<comp_wa>-length, <comp_wa>-decimals.
ENDLOOP. -
Colour to field in an internal table
how to colour a particular data in a particular field of an internal table.
See this
1. add one more field to ur final internal table say COLOR(4)
2. in layout wa_layout-style_fname = 'COLOR'. " if its grid
wa_layout-style_fieldname = 'COLOR'. "if its list
3. read table itab index 3.
itab-color = 'C410'.
modify itab index 3
4. see program SHOWCOLO for all color codes
1. Add a field of data type CHAR(3) to the internal output table.
2. Enter the color code in the appropriate field of the row to be colored in the internal
output table:
Code: 'Cxy'
C = Color (all codes begin with 'C')
x = color number ('1' - '9')
y = highlight ('0' = off, '1' = on)
3. Assign the internal output table color code field name to the IS_LAYOUT importing
structure IS_LAYOUT-INFO_FIELDNAME field and pass this structure in the ALV call
interface.
To enable row coloring, you should add an additional field to your list data table. It should be of character type and length at least 4. This field will contain the color code for the row. So, lets modify declaration of our list data table gt_list.
you should fill the color code to this field. Its format will be the same as explained before at section C.6.3. But how will ALV Grid know that you have loaded the color data for the row to this field. So, you make it know this by passing the name of the field containing color codes to the field INFO_FNAME of the layout structure.
e.g.
ps_layout-info_fname = <field_name_containing_color_codes>. e.g. ROWCOLOR
You can fill that field anytime during execution. But, of course, due to the flow logic of screens, it will be reflected to your list display as soon as an ALV refresh occurs.
You can color an entire row as described in the next section. However, this method is less time consuming.
Coloring Individual Cells
This is the last point about coloring procedures for the ALV Grid. The procedure is similar to coloring an entire row. However, since an individual cell can be addressed with two parameters we will need something more. What is meant by more is a table type structure to be included into the structure of the list data table. It seems strange, because including it will make our list data structure deep. But anyhow ALV Grid control handles this.
The structure that should be included must be of type LVC_T_SCOL. If you want to color the entire row, this inner table should contain only one row with field fname is set to space, some color value at field col, 0 or 1 at fields int (intensified) and inv (inverse).
If you want to color individual cells, then for each cell column, append a line to this inner table which also contains the column name at field fname. It is obvious that you can color an entire column by filling this inner table with a row for that column for each row in the list data table.
If it is in ALv refer the following code:
*& Report ZDEMO_ALVGRID *
*& Example of a simple ALV Grid Report *
*& The basic ALV grid, Enhanced to display each row in a different *
*& colour *
REPORT zdemo_alvgrid .
TABLES: ekko.
type-pools: slis. "ALV Declarations
*Data Declaration
TYPES: BEGIN OF t_ekko,
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
statu TYPE ekpo-statu,
aedat TYPE ekpo-aedat,
matnr TYPE ekpo-matnr,
menge TYPE ekpo-menge,
meins TYPE ekpo-meins,
netpr TYPE ekpo-netpr,
peinh TYPE ekpo-peinh,
line_color(4) type c, "Used to store row color attributes
END OF t_ekko.
DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
wa_ekko TYPE t_ekko.
*ALV data declarations
data: fieldcatalog type slis_t_fieldcat_alv with header line,
gd_tab_group type slis_t_sp_group_alv,
gd_layout type slis_layout_alv,
gd_repid like sy-repid.
*Start-of-selection.
START-OF-SELECTION.
perform data_retrieval.
perform build_fieldcatalog.
perform build_layout.
perform display_alv_report.
*& Form BUILD_FIELDCATALOG
Build Fieldcatalog for ALV Report
form build_fieldcatalog.
There are a number of ways to create a fieldcat.
For the purpose of this example i will build the fieldcatalog manualy
by populating the internal table fields individually and then
appending the rows. This method can be the most time consuming but can
also allow you more control of the final product.
Beware though, you need to ensure that all fields required are
populated. When using some of functionality available via ALV, such as
total. You may need to provide more information than if you were
simply displaying the result
I.e. Field type may be required in-order for
the 'TOTAL' function to work.
fieldcatalog-fieldname = 'EBELN'.
fieldcatalog-seltext_m = 'Purchase Order'.
fieldcatalog-col_pos = 0.
fieldcatalog-outputlen = 10.
fieldcatalog-emphasize = 'X'.
fieldcatalog-key = 'X'.
fieldcatalog-do_sum = 'X'.
fieldcatalog-no_zero = 'X'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'EBELP'.
fieldcatalog-seltext_m = 'PO Item'.
fieldcatalog-col_pos = 1.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'STATU'.
fieldcatalog-seltext_m = 'Status'.
fieldcatalog-col_pos = 2.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'AEDAT'.
fieldcatalog-seltext_m = 'Item change date'.
fieldcatalog-col_pos = 3.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'MATNR'.
fieldcatalog-seltext_m = 'Material Number'.
fieldcatalog-col_pos = 4.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'MENGE'.
fieldcatalog-seltext_m = 'PO quantity'.
fieldcatalog-col_pos = 5.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'MEINS'.
fieldcatalog-seltext_m = 'Order Unit'.
fieldcatalog-col_pos = 6.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'NETPR'.
fieldcatalog-seltext_m = 'Net Price'.
fieldcatalog-col_pos = 7.
fieldcatalog-outputlen = 15.
fieldcatalog-datatype = 'CURR'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'PEINH'.
fieldcatalog-seltext_m = 'Price Unit'.
fieldcatalog-col_pos = 8.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
endform. " BUILD_FIELDCATALOG
*& Form BUILD_LAYOUT
Build layout for ALV grid report
form build_layout.
gd_layout-no_input = 'X'.
gd_layout-colwidth_optimize = 'X'.
gd_layout-totals_text = 'Totals'(201).
Set layout field for row attributes(i.e. color)
gd_layout-info_fieldname = 'LINE_COLOR'.
gd_layout-totals_only = 'X'.
gd_layout-f2code = 'DISP'. "Sets fcode for when double
"click(press f2)
gd_layout-zebra = 'X'.
gd_layout-group_change_edit = 'X'.
gd_layout-header_text = 'helllllo'.
endform. " BUILD_LAYOUT
*& Form DISPLAY_ALV_REPORT
Display report using ALV grid
form display_alv_report.
gd_repid = sy-repid.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = gd_repid
i_callback_top_of_page = 'TOP-OF-PAGE' "see FORM
i_callback_user_command = 'USER_COMMAND'
i_grid_title = outtext
is_layout = gd_layout
it_fieldcat = fieldcatalog[]
it_special_groups = gd_tabgroup
IT_EVENTS = GT_XEVENTS
i_save = 'X'
is_variant = z_template
tables
t_outtab = it_ekko
exceptions
program_error = 1
others = 2.
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
endform. " DISPLAY_ALV_REPORT
*& Form DATA_RETRIEVAL
Retrieve data form EKPO table and populate itab it_ekko
form data_retrieval.
data: ld_color(1) type c.
select ebeln ebelp statu aedat matnr menge meins netpr peinh
up to 10 rows
from ekpo
into table it_ekko.
*Populate field with color attributes
loop at it_ekko into wa_ekko.
Populate color variable with colour properties
Char 1 = C (This is a color property)
Char 2 = 3 (Color codes: 1 - 7)
Char 3 = Intensified on/off ( 1 or 0 )
Char 4 = Inverse display on/off ( 1 or 0 )
i.e. wa_ekko-line_color = 'C410'
ld_color = ld_color + 1.
Only 7 colours so need to reset color value
if ld_color = 8.
ld_color = 1.
endif.
concatenate 'C' ld_color '10' into wa_ekko-line_color.
wa_ekko-line_color = 'C410'.
modify it_ekko from wa_ekko.
endloop.
endform. " DATA_RETRIEVAL
Please give me reward points... -
Extract a value of a fields from an internal table
hello everyone,
i need to extract a value of a fields from an internal table, the fields is in a postion "sy-tabix" that i know, so i need to pick this value without using a loop
thank you.Like this?
DATA: FIELD1 TYPE C,
FIELD2 TYPE C.
READ TABLE T_TAB INDEX 3.
FIELD1 = T_TAB-FIELD1.
FIELD2 = T_TAB-FIELD2.
Greetings,
Blag. -
Field catalog for internal table in ALV
In my program the internal table consists many fields from various tables and structure doesn't belong to a single data table.
In order to get output in ALV grid following FM has been used
REUSE_ALV_GRID_DISPLAY
for field catalog the fields are defined specifically.
l_fieldcat-fieldname = 'VBELN'.
l_fieldcat-outputlen = 10.
l_fieldcat-seltext_l = 'Billing doc'.
l_fieldcat-no_zero = 'X'.
l_fieldcat-hotspot = 'X'.
append l_fieldcat to p_fieldtab.
..............and so on for all the fields.
Just wanted to know is there any other method to display all the fields of this internal table automatically so each field is not specified specifically.
anyaHi
Try this instead:
*& Form create_fieldcatalog
* Create a field catalogue from any internal table
* -->PT_TABLE Internal table
* -->PT_FIELDCAT Field Catalogue
FORM create_fieldcatalog
USING pt_table TYPE ANY TABLE
CHANGING pt_fieldcat TYPE lvc_t_fcat.
DATA:
lr_tabdescr TYPE REF TO cl_abap_structdescr
, lr_data TYPE REF TO data
, lt_dfies TYPE ddfields
, ls_dfies TYPE dfies
, ls_fieldcat TYPE lvc_s_fcat
CLEAR pt_fieldcat.
CREATE DATA lr_data LIKE LINE OF pt_table.
lr_tabdescr ?= cl_abap_structdescr=>describe_by_data_ref( lr_data ).
lt_dfies = cl_salv_data_descr=>read_structdescr( lr_tabdescr ).
LOOP AT lt_dfies
INTO ls_dfies.
CLEAR ls_fieldcat.
MOVE-CORRESPONDING ls_dfies TO ls_fieldcat.
APPEND ls_fieldcat TO pt_fieldcat.
ENDLOOP.
ENDFORM. "create_fieldcatalog -
How to find number of fields in an internal table ?
my requirement is i have 20 internal tables and the data is being uploaded into an application server. so how to find no of fields in a particular internal tableconcatenate all the fields and move them to final internal table , call the function module "GET_COMPONENT_LIST" and pass the work area of the final internal table in the parameter fieldname
***For getting no of FIELDS in an internal table ********
CALL FUNCTION 'GET_COMPONENT_LIST'
EXPORTING
PROGRAM = syrepid
FIELDNAME = 't_payr'
TABLES
COMPONENTS = fieldlist.
describe table fieldlist lines pyr_no_fields.
********end of getting no of fields**********
TRANSFER wa_mat_out_head TO P_FNAME.
LOOP AT GT_PAYR.
MOVE: GT_payr-LIFNR TO T_payr-lifnr,
GT_payr-ZBUKR TO T_payr-zbukr,
GT_payr-LAUFD TO T_payr-LAUFD,
GT_payr-CHECT TO T_payr-CHECT,
GT_payr-RWBTR TO T_payr-RWBTR.
Concatenate T_payr-lifnr t_payr-zbukr T_payr-laufd T_payr-chect
T_payr-rwbtr into wa_mat_out-rec SEPARATED by ',' . -
Changing the order of fields in an internal table
Hi all,
I'm using field symbol as internal table. this table has got a standard database structure.
I want to make the 3rd column of this internal table as 1st colums keeping rest of the columns as it is.
Is there any way to do this?
Thanks,
Anil.Hi
Instead of directly taking the type as a standard structure , declare the FS internal table as type of types structure.
Data: fs_scarr like type_s_scarr.
FIELD-SYMBOLS <scarr2> TYPE fs_scarr
In the types put the third column as first one and use into corresponding in select query
or else
while displaying the internal table change the order of the columns
Loop at itab into fs_itab.
write : col3
col2
col4
endloop.
Thanks,
Viquar Iqbal -
Aggregate a numeric field in an internal table
Hi All,
I have a small requirement in ABAP it goes in this fashion
I need to aggregate a numeric field in an internal table, the table is as follows
FLD1 FLD2 NUM1 FLD3
123A B1 10 C1
123A B1 25 C1
123B B1 20 C2
123C B2 10 C3
Note: FLD1, FLD2, FLD3 are of type numeric characters and NUM1 is of type number or integer
I want the result to be as follows
FLD1 FLD2 NUM1 FLD3
123A B1 35 C1
123B B1 20 C2
123C B2 10 C3
i.e. values in field NUM1 should get add up when the values in all other fields are same
I am not able to use _collect_ for this as the fields contain numeric characters.
Regards and Thanks,
AntonyHi Antony
collect here works like this:-
use at new field
sum
end at.
Pls reward points if it wil be helpful.
Regards
Depanker -
I need to add check whether 21 fields of a internal table are empty or not.
Hello,
I need to add check whether 21 fields of a internal table are empty or not.How can we write a code for the same wand what would be the correct syntax for it.
I tried entering all the fields in the IF loop with AND condition but its giving syntax error.Perhaps this is because the lenght of the IF condition would be more than the allowed one.Hi,
After the select quiery.
If not itab is initial.
Message 'Table is not empty' type 'I'.
Endif.
Regards,
Jagadish. -
First occurence of a value from a field in the internal table.
How to select the first occurence of a value from a field in an internal table ?
I don think , we can use select query .
Any suggestions?
provide syntaxs also .Hi...
You have to use this code.
DATA : Begin of IT_MARA occurs 0,
mtart type mara-mtart,
matnr type mara-matnr,
meins type mara-meins,
END OF IT_MARA.
START-of-SELECTION.
SELECT MTART MATNR MEINS FROM MARA INTO TABLE IT_MARA.
END-OF-SELECTION.
LOOP AT IT_MARA.
<b> AT NEW MTART. "This will trigger for every first/new value of the field
<<<<WRITE YOUR CODE here>>
ENDAT.</b>
ENDLOOP.
You can also use.
LOOP AT IT_MARA.
<b> <b> ON CHANGE OF IT_MARA-TART.
<<<<WRITE YOUR CODE here>>
ENDON.</b></b>
ENDLOOP.
<b>Reward if Helpful.</b> -
Coloring a field in the internal table
Hi all,
How can I color a field in the internal table knowing that I'm developing a classic report.
Thanks in advance.hi,,,
check this code.
*-----TABLES DECLARATION
tables : kna1, "Customer Master
vbak, "Sales Document Header
vbap, "Sales Document Item
sscrfields. "Screen Field Table
& D A T A D E C L A R A T I O N &
data : begin of it_kna1 occurs 0,
kunnr type kna1-kunnr, "Customer Number
land1 type kna1-land1, "Country Key
name1 type kna1-name1, "Name
ort01 type kna1-ort01, "City
end of it_kna1.
data : begin of it_kna2 occurs 0,
kunnr type kna1-kunnr, "Customer Number
land1 type kna1-land1, "Country Key
name1 type kna1-name1, "Name
ort01 type kna1-ort01, "City
end of it_kna2.
data: begin of it_vbak occurs 0,
vbeln type vbak-vbeln, "Sales Document
erdat type vbak-erdat, "Date
ernam type vbak-ernam, "Name of Person
auart type vbak-auart, "Sales Document Type
end of it_vbak.
data: begin of it_vbap occurs 0,
vbeln type vbap-vbeln, "Sales Document
posnr type vbap-posnr, "Sales Document Item
matnr type vbap-matnr, "Material Number
matkl type vbap-matkl, "Material group
end of it_vbap.
data: v_count type int4, "Current Row Index
v_line like sy-lisel, "Contents of selected line
v_kunnr like kna1-kunnr.
& S E L E C T I O N S C R E E N &
selection-screen begin of block b1 with frame title text-001.
selection-screen begin of line.
parameters : rb1 radiobutton group g1 default 'X'.
selection-screen comment 5(20) text-002 for field rb1.
selection-screen end of line.
select-options : so_kunnr for kna1-kunnr obligatory.
parameters : p_hits(3) type c.
selection-screen begin of line.
parameters : rb2 radiobutton group g1.
selection-screen comment 5(20) text-003 for field rb2.
selection-screen end of line.
parameters : p_file like rlgrap-filename default 'c:\test'.
selection-screen pushbutton /33(10) custl user-command push1.
selection-screen pushbutton 58(10) custd user-command push2.
selection-screen end of block b1.
& I N I T I A L I Z A T I O N &
initialization.
move 'LOAD' to custl.
move 'DISP' to custd.
& A T L I N E S E L E C T I O N &
at selection-screen.
perform validate_kunnr.
& A T S E L E C T I O N S C R E E N O N V A L U E-R E Q U E S T &
at selection-screen on value-request for p_file.
call function 'F4_FILENAME'
exporting
program_name = syst-cprog
dynpro_number = syst-dynnr
field_name = ' '
importing
file_name = p_file.
& S T A R T O F S E L E C T I O N &
start-of-selection.
perform cust_details.
& S T A R T O F S E L E C T I O N &
top-of-page.
format color 3 intensified off.
write :/02(25) sy-repid.
write : 39(15) 'Page'(010), sy-pagno.
format color off.
format color 6 intensified off.
format color col_heading.
uline at :/1(60).
write: /1 sy-vline,
2 'Cust Number'(000),
14 sy-vline,
16 'Country'(007),
25 sy-vline,
26 'City'(008),
42 sy-vline,
43 'Region'(009),
60 sy-vline.
uline at :/1(60).
format color col_heading off.
& T O P O F P A G E D U R I N G L I N E S E L E C T I O N &
top-of-page during line-selection.
if sy-lsind eq 1 or sy-ucomm eq 'VBAK'.
format color col_heading.
uline at :/1(60).
write : /1 sy-vline,
2 'Docu No.'(011),
14 sy-vline,
16 'Date'(012),
26 sy-vline,
27 'Name'(013),
42 sy-vline,
43 'DType'(014),
60 sy-vline.
uline at :/1(60).
elseif sy-lsind eq 2 or sy-ucomm eq 'VBAK'.
set pf-status space.
uline at :/1(60).
write : /1 sy-vline,
2 'Docu No.'(015),
14 sy-vline,
16 'Sales Item'(016),
25 sy-vline,
26 'Mat No'(017),
42 sy-vline,
43 vbap-matkl,
50 'Mat Grp'(018),
60 sy-vline.
uline at :/1(60).
endif.
& AT USER-COMMAND &
at user-command.
case sy-ucomm.
when 'VBAK'.
perform sales_item.
when 'DELIVERY'.
clear it_vbak-vbeln.
get cursor value it_vbak-vbeln.
set parameter id 'AUN' field it_vbak-vbeln.
call transaction 'VA03' and skip first screen.
when 'DISP'.
perform display_basic.
endcase.
& AT LINE SELECTION &
at line-selection.
if sy-lsind = 1.
set pf-status 'DDDD'.
perform sales_header.
elseif sy-lsind = 2.
case sy-ucomm.
when 'PICK'.
set pf-status space.
perform sales_item.
when 'DELIVERY'.
clear it_vbak-vbeln.
get cursor value it_vbak-vbeln.
set parameter id 'AUN' field it_vbak-vbeln.
call transaction 'VA03' and skip first screen.
when 'DISP'.
perform display_basic.
endcase.
PERFORM sales_item.
endif.
& AT USER-COMMAND &
at user-command.
case sy-ucomm.
when 'VBAK'.
perform sales_item.
when 'DELIVERY'.
clear it_vbak-vbeln.
get cursor value it_vbak-vbeln.
set parameter id 'AUN' field it_vbak-vbeln.
call transaction 'VA03' and skip first screen.
when 'DISP'.
perform display_basic.
endcase.
& Form CUST_DETAILS &
form cust_details .
select kunnr
land1
name1
ort01
from kna1
into table it_kna1
where kunnr in so_kunnr.
if sy-subrc <> 0.
message 'SELECT VALID CUST NO' type 'I'.
else.
loop at it_kna1.
v_count = v_count + 1.
if sy-tabix < p_hits.
IF v_count <= p_hits.
move it_kna1 to it_kna2.
append it_kna2.
else.
exit.
endif.
endloop.
endif.
if not it_kna2[] is initial.
loop at it_kna2.
write : /1 sy-vline,
2 it_kna2-kunnr,
14 sy-vline,
16 it_kna2-land1,
25 sy-vline,
26 it_kna2-name1,
42 sy-vline,
43 it_kna2-ort01,
60 sy-vline.
uline at :/1(60).
endloop.
endif.
endform. " CUST_DETAILS
**& Form load_file
*form load_file .
*endform. " load_file
**& Form disp_file
*form disp_file .
*endform. " disp_file
*& Form VALIDATE_KUNNR
form validate_kunnr .
select single kunnr
from kna1
into kna1
where kunnr = so_kunnr.
endform. " VALIDATE_KUNNR
*& Form SALES_HEADER
form sales_header .
data : v_kna1(13).
v_kna1 = 'IT_KNA2-KUNNR'.
*get cursor line sy-lilli value v_line
clear v_kunnr.
get cursor field v_kna1 value v_kunnr.
v_kunnr = v_line+1(10).
call function 'CONVERSION_EXIT_ALPHA_INPUT'
exporting
input = v_kunnr
importing
output = v_kunnr.
select vbeln
erdat
ernam
auart
from vbak
into table it_vbak
where kunnr = v_kunnr.
if sy-subrc = 0.
loop at it_vbak.
write : /1 sy-vline,
2 it_vbak-vbeln,
14 sy-vline,
16 it_vbak-erdat,
26 sy-vline,
27 it_vbak-ernam,
42 sy-vline,
43 it_vbak-auart,
60 sy-vline.
uline at :/1(60).
endloop.
endif.
endform. " SALES_HEADER
*& Form SALES_ITEM
form sales_item .
data : v_vbeln(13).
v_vbeln = 'IT_VBAK-VBELN'.
clear it_vbak-vbeln.
get cursor field v_vbeln value it_vbak-vbeln.
call function 'CONVERSION_EXIT_ALPHA_INPUT'
exporting
input = it_vbak-vbeln
importing
output = it_vbak-vbeln.
select vbeln
posnr
matnr
matkl
from vbap
into table it_vbap
where vbeln = it_vbak-vbeln.
loop at it_vbap .
write : /1 sy-vline,
2 it_vbap-vbeln,
14 sy-vline,
16 it_vbap-posnr,
25 sy-vline,
26 it_vbap-matnr,
42 sy-vline,
43 it_vbap-matkl,
60 sy-vline.
uline at :/1(60).
endloop.
endform. " SALES_ITEM
*& Form DISP_DOCU
form display_basic .
loop at it_kna1 into it_kna1.
format hotspot on.
write : /03 it_kna1-kunnr,
24 it_kna1-name1.
hide it_kna1-kunnr.
endloop.
endform. " display_basic
pls reward if useful
regards,
rekha -
Add field in an internal table
Hi There,
How to add a field in an internal table created at the runtime using
CREATE DATA D1 TYPE TABLE OF (VAR).
where say var contains name of a DDIC table.
Rgds,
deb.after creating internal table use the method for creation of dynamic table and try , i am not sure
DATA: LineType TYPE string,
ItabRef TYPE REF TO DATA.
FIELD-SYMBOLS: TYPE STANDARD TABLE.
LineType = 'SFLIGHT'.
" Create internal table and attach a field-symbol
CREATE DATA ItabRef TYPE STANDARD TABLE OF (LineType).
ASSIGN ItabRef->* TO .
<b>after this check this and try</b>
******DATA DECLARATION*****************************
FIELD-SYMBOLS : <it_final> TYPE STANDARD TABLE,
<wa_final> TYPE ANY,
<w_field> TYPE ANY.
***DYNAMIC CREATION OF FIELDCATALOG****************
*FIRST 2 FIELDS FIELDS FIELD1 AND FIELD2 ARE CONSTANT, FIELDS OBTAINED IN THE LOOP ENDLOOP ARE DYNAMIC,
*LIKEWISE DYNAMIC FIELDCATALOG IS CREATED
wa_fieldcatalog-fieldname = 'FIELD1'.
wa_fieldcatalog-ref_table = 'E070'.
wa_fieldcatalog-outputlen = '13'.
wa_fieldcatalog-reptext = 'Created On'.
wa_fieldcatalog-seltext = 'Created On'.
APPEND wa_fieldcatalog TO it_fieldcatalog.
CLEAR wa_fieldcatalog.
wa_fieldcatalog-fieldname = 'FIELD1'.
wa_fieldcatalog-ref_table = 'E070'.
wa_fieldcatalog-outputlen = '13'.
wa_fieldcatalog-reptext = 'Created On'.
wa_fieldcatalog-seltext = 'Created On'.
APPEND wa_fieldcatalog TO it_fieldcatalog.
CLEAR wa_fieldcatalog.
LOOP AT it_mandt WHERE mandt IN s_mandt.
CONCATENATE 'CLNT' it_mandt INTO wa_fieldcatalog-fieldname.
wa_fieldcatalog-inttype = 'NUMC'.
wa_fieldcatalog-outputlen = '14'.
wa_fieldcatalog-reptext = it_mandt.
wa_fieldcatalog-seltext = it_mandt.
APPEND wa_fieldcatalog TO it_fieldcatalog.
CLEAR :wa_fieldcatalog ,it_mandt.
ENDLOOP.
********CREATE DYNAMIC TABLE************************
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = it_fieldcatalog
IMPORTING
ep_table = new_table
EXCEPTIONS
generate_subpool_dir_full = 1
OTHERS = 2.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ASSIGN new_table->* TO <it_final>.
*********CREATE WORK AREA****************************
CREATE DATA new_line LIKE LINE OF <it_final>.
ASSIGN new_line->* TO <wa_final>.
*********INSERTTING WORK AREAR TO INTERNAL TABLE******
INSERT <wa_final> INTO TABLE <it_final>.
*******POPULATING DATA*******************************
LOOP.
ASSIGN COMPONENT 'FIELD1' OF STRUCTURE <wa_final> TO <w_field>.
<w_field> = '12345'.
ASSIGN COMPONENT 'FIELD2' OF STRUCTURE <wa_final> TO <w_field>.
<w_field> = '21453DD'.
FIELD1 AND FIELD2 ARE COMPONENTS OF FIELDCATALOG.
ENDLOOP.
ENDLOOP.
Maybe you are looking for
-
Which Macbook Pro is good for a college student?
Hi! I want to buy the new Macbook Pro with Retina Display. My current laptop has 455 gb in which I only used 83 gb of it since the past 5 years I've been using it. I know that the original macbook pro is good too but its way heavier than the Macbook
-
Application Paint() Help
Hi, I am making a game, but sometimes when I activate it, I will get a nullpointerexception (varies greatly). Also, when I try to have the About class paint, it only works the second time through. I would greatly appriciate any help! import java.awt.
-
I've reinstalled the latest itunes but it will noit open I get an error message
I've recently had to reinstall itunes and now it won't open I get an error message
-
Temporarily Disable Start-Up Items
Hi, I just updated to Snow Leopard and in the process I have come to discover that my Symantic Anti-Virus is incompatible with the upgrade. I need to keep the software on my computer since it is required by my college to have it, however I would like
-
Adobe Photoshop opens automatically when iPod or iPhone connected.
OK, who has a solution for me? I have my iTunes preferences set to NOT download photos to/from iPod or iPhone. Yet, after the last iTunes upgrade/update, now Adobe Photoshop automatically opens and searches for pictures to download/upload. How can I