Concatenate Primary Key Fields of an internal table into a String.
Hi,
I have a dynamic internal table created.
In the dynamic internal table,
How to concatenate all the primary keys of that row concatenated into a string and non primary keys into a different string.
Can some one help me on this.
E.g:
Itab1 has 3 Primary fields and 3 Non primary key fields and it has 2 records.
Table col1 col2 col3 col4 col5 col6
Row1 AA AB AC 1 2 3
Row2 ZA ZB ZC 1 2 3
The following is needed.
Itab2 will have the concatenate strings
Key Nkey
Row1 AAABAC 010203
Row2 ZAZBZC 010203
Thanks,
Chaithanya
C,
Try something like this - Use an ASSIGN in a LOOP:
data: lv_PK type string.
data: lv_non_PK type string.
field-symbols: lv_str type string.
assign local copy of initial line of gt_table to <ls_table>.
loop at gt_table. " this is your table.
do n times. " n = 6 in your case
if n < 4.
assign component sy-index of structure <ls_table> to <lv_str>.
concatenate <lv_str> to lv_PK.
else.
assign component sy-index of structure <ls_table> to <lv_str>.
concatenate <lv_str> to lv_Non_PK.
endif.
enddo.
append <ls_table> to <gt_table>.
endloop.
Similar Messages
-
Adding 2 new fields as Primary Key field in a Z Table which is existing PRD
Hi Friends,
I have to add two new fields as primary key fields in a Z TABLE, which is existing in Quality and Production Systems with Data.
If I incorporate these two new fields (Primary Key fields) in development and if the TR is moved to Quality and Production sytems, is there any possibility of loss in data will happen at Quality and Prd systems?
At present, Table is having 20 fields with 2 primary key fields and i have to add 2 more primary key fields.
I have checked in SCN and not find relevant threads.
Please help me out.
Regards,
Suresh.NO . It wont be a problem .
For ex :
If you have VBELN , POSNR are key fields now , you have an unique reord with that combination .
If you add one other field in it fo ex VKBUR then records will be like this
VBELN POSNR VKBUR MATERIAL QTY
10020 10 abcxyz 1
10020 10 1234 abcxyz 1
So your previous records before adding new primary keys , will have new fields balnk , and the new records will have data filled up in all primary key fields .
However , if you try to update the existing records that will be in existing PRIMARYKEY combination only .
for example if you try update record 1 above with VKBUR value 85858 , it creates a new record , it wont be updated in existing record.
Hope this helps , Pls let me know if u have any more doubts. -
Default Primary Key Field of any database table
hi,
I am working on a database in which the data in the tables is generated from some other modules. I have to add, view and update functionalities to this table in the database. Unfortunately there is no primary key field for the table i am working on and as some existing modules are using this table i am not allowed to change the design of the table at this stage.
Without primary i think its not possible to do updates. Because if all fields can have their values changed, then there will be a breakdown if the field value changes in the mid time when i had already retrieved the data to show on the screen, but not yet updated the value in the database. I hope you understood my problem.
Please suggest solutions. I am not sure, but i think i read somewhere that every table created has a default primary associated whose value is always incresing with a new addtion of recored and its value never decreases. But i am unable to recollect the field name...i think it is some thing like[b] OID .... But i checked there is no such field name by OID. So please help me with some alternative solution...or by telling the default primary key field name.
ThanxAll the databases I know (namely Informix, PostgreSQL, SQL Server, even Access) have a row id column generated automatically.
PostgreSQL example
There is a way to read the value of this column; for example with PostgreSQL let�s say you have the following:
CREATE TABLE no_id_column (
column_one varchar(80),
column_two varchar(80)
INSERT INTO no_id_column(column_one, column_two) VALUES (�red�, �pink�);
INSERT INTO no_id_column(column_one, column_two) VALUES (�yellow�, �orange�);Certainly, if we executed:
SELECT * FROM no_id_column;Would obtain:
column_one column_two
red pink
yellow orangeBut if we modify the query
SELECT oid, * FROM no_id_column;We magically obtain a row identificator
oid column_one column_two
21569 red pink
21570 yellow orangeThe data in the oid column is generated automatically by the database manager. Every time we insert a row we�ll have a different one. Just take into account that if the database contains a large amount of data, the oid could cycle. -
How many primary key fields allowed for one table?
hi,
when i creating a table , how many primary key fields are allowed for one table.
please any one give ans
thanksJust checked it, Its 255, not 155. You can have as many key fields as you want, but you can not go over the 255 byte length for the total of all key fields. You will get a warning for over 120, as it says that there is limited functionality with a key over 120 in length.
Again, this is a total length of all key fields.
Regards,
Rich Heilman -
Merge an internal table into a string stream
Hello,
i need to merge an internal table (2 column) layout:
ELEMENT
VALUE
into one string stream.
E.g.:
ELEMENT | VALUE
test1 | 1111111111111111111
test1 | 2222222222222222222
result should be:
test1 | 11111111111111111112222222222222222222 (= type string!)
too bad you cant use offset while working with a field of type string and im sure there is a ABAP class which does do this.
regards,
MarkusTry this Markus:
REPORT ztest NO STANDARD PAGE HEADING LINE-SIZE 255.
DATA: BEGIN OF itab OCCURS 0,
element TYPE string,
value TYPE string,
END OF itab.
DATA: BEGIN OF itab2 OCCURS 0,
element TYPE string,
value TYPE string,
END OF itab2.
DATA: next LIKE sy-tabix VALUE 1,
old_element LIKE itab-element.
PERFORM load_itab.
sy-subrc = 0.
DO.
READ TABLE itab INDEX next.
IF sy-subrc <> 0.
EXIT.
ELSE.
IF itab-element <> old_element.
IF next <> 1.
APPEND itab2.
CLEAR itab2.
ENDIF.
itab2-element = itab-element.
old_element = itab-element.
ENDIF.
CONCATENATE itab2-value itab-value INTO itab2-value.
next = next + 1.
ENDIF.
ENDDO.
IF itab2-element <> space.
APPEND itab2.
ENDIF.
break rburbank.
*& Form load_itab
* text
FORM load_itab.
REFRESH: itab,
itab2.
CLEAR : itab,
itab2.
itab-element = 'test1'.
itab-value = '1111111111111111111'.
APPEND itab.
itab-element = 'test1'.
itab-value = '2222222222222222222'.
APPEND itab.
itab-element = 'test2'.
itab-value = '3333333333333333333'.
APPEND itab.
itab-element = 'test2'.
itab-value = '4444444444444444444'.
APPEND itab.
ENDFORM. " load_itab
Rob -
Problems deleting a primary key field in a table.
Hello Guys,
I deleted a primary key field in a custom table by clicking 'delete row' icon and then tried activating it through se14 - database utility. It is throwing an error saying 'Primary key change not permited for the value table zxxxx'. What is the problem???
How can I delete a primary key in a table??
Please help.
Thanks,
NarenI am pasting the detail explaination over that error.
Primary key change not permitted for value table ZTV_RANGE_NUMBER
Message no. AD 300
Diagnosis
This table is defined as a check table. For reasons of consistency, changes to the primary key of the table are not allowed.
Procedure
If it is essential that you change the primary key, you must delete the relevant foreign keys. Refer to the where-used list to find all tables containing a field that is checked against this table. Delete the foreign keys for these fields.
If necessary, maintain the deleted foreign keys again. -
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 -
Updation of Primary Key field in HR Tables (PA2001 and PA2002) - Urgent
Can anyone please tell me how to update a primary key field in HR Tables (PA2001 and PA2002).
I need to update sprps field in both the tables. I used HR_Infotype_Operation function module, but still it is not updating the field.
Pls find the following code snippet for the table PA2001 and let me know if any discrepancies :
TABLES: pa2001.
DATA: it_pa2001 TYPE TABLE OF pa2001,
wa_pa2001 LIKE LINE OF it_pa2001,
DATA: date TYPE d.
date = sy-datum - 100.
SELECT pernr sprps begda endda FROM PA2001 INTO CORRESPONDING FIELDS OF TABLE it_pa2001
WHERE begda BETWEEN date and sy-datum.
WRITE:/.
WRITE:/ 'PA 2001 Records'.
if sy-subrc <> 0.
WRITE:/ 'No Data Exists'.
else.
LOOP AT it_pa2001 INTO wa_pa2001.
WRITE:/ wa_pa2001-pernr, wa_pa2001-sprps, wa_pa2001-begda, wa_pa2001-endda.
ENDLOOP.
endif.
LOOP AT it_pa2001 INTO wa_pa2001.
wa_pa2001-sprps = 'X'.
CALL FUNCTION 'HR_INFOTYPE_OPERATION'
EXPORTING
infty = '2001'
number = wa_pa2001-pernr
SUBTYPE =
OBJECTID =
LOCKINDICATOR =
VALIDITYEND =
VALIDITYBEGIN =
RECORDNUMBER =
record = wa_pa2001
operation = 'MOD'
TCLAS = 'A'
DIALOG_MODE = '0'
NOCOMMIT =
VIEW_IDENTIFIER =
SECONDARY_RECORD =
IMPORTING
RETURN =
KEY =
ENDLOOP.
if sy-subrc = 0.
write:/ 'SY-subrc is zero'.
write:/ ' Rows modified = ', sy-dbcnt.
else.
write:/ 'No Record(s) updated'.
endif.
commit work.
WRITE: / 'Updated Records in the Internal Table IT_PA2001'.
SELECT pernr sprps begda endda FROM PA2001 INTO CORRESPONDING FIELDS OF TABLE it_pa2001
WHERE begda BETWEEN date AND sy-datum..
LOOP AT it_pa2001 INTO wa_pa2001.
WRITE:/ wa_pa2001-pernr, wa_pa2001-sprps, wa_pa2001-begda, wa_pa2001-endda.
ENDLOOP.Thanks Kiran.
But I need to change this field as we need to lock the records, as soon as the employee fills his/her time sheets which will be sent for HR Payroll, later on.
When I am updating directly the field the database table PA2001, its not updating but for table PA2002, only few records are being updated.
Is there any other alternative for this problem?
Pls reply.
Thanks,
Harish -
How to add a new data element for existing table filed(Primary key field)
Hi Experts,
How to add a new data element for existing table field(Primary key field)
For this filed ther is no foreign key relation ships and even check table.
while activating table it is giving message like below.
can you help any one to solve this and wil steps to add new dataelement for existing primary key filed of a table.
Check table (NAMING SPACE/TABLE NAME(EX:/TC/VENDOR)) (username/19.02.10/03:29)
Primary key change not permitted for value table /TC/VENDOR
Check on table /TC/VENDOR resulted in errors
Thanks
RaviHi,
Easiest way is to download the table eg into an Excel table (if possible) or text table. Drop the table from the database. Build your table with the new key field. Build the database table again and fill it.
You can do it also over the database into a new table. Drop the old one. Build the enhanced one and fill it. Afterwards drop your (temporary) table.
Maybe there are other ways, but this works.
Success,
Rob -
Prob with Updation of Primary Key field '' SPRPS '' in PA2001. Plz HELP
Can anyone please tell me how to update a primary key field in HR Tables (PA2001 and PA2002).
I need to update sprps field in both the tables. I used HR_Infotype_Operation function module, but still it is not updating the field.
Pls find the following code snippet for the table PA2001 and let me know if any discrepancies :
TABLES: pa2001.
DATA: it_pa2001 TYPE TABLE OF pa2001,
wa_pa2001 LIKE LINE OF it_pa2001,
DATA: date TYPE d.
date = sy-datum - 100.
SELECT pernr sprps begda endda FROM PA2001 INTO CORRESPONDING FIELDS OF TABLE it_pa2001
WHERE begda BETWEEN date and sy-datum.
WRITE:/.
WRITE:/ 'PA 2001 Records'.
if sy-subrc <> 0.
WRITE:/ 'No Data Exists'.
else.
LOOP AT it_pa2001 INTO wa_pa2001.
WRITE:/ wa_pa2001-pernr, wa_pa2001-sprps, wa_pa2001-begda, wa_pa2001-endda.
ENDLOOP.
endif.
LOOP AT it_pa2001 INTO wa_pa2001.
wa_pa2001-sprps = 'X'.
CALL FUNCTION 'HR_INFOTYPE_OPERATION'
EXPORTING
infty = '2001'
number = wa_pa2001-pernr
SUBTYPE =
OBJECTID =
LOCKINDICATOR =
VALIDITYEND =
VALIDITYBEGIN =
RECORDNUMBER =
record = wa_pa2001
operation = 'MOD'
TCLAS = 'A'
DIALOG_MODE = '0'
NOCOMMIT =
VIEW_IDENTIFIER =
SECONDARY_RECORD =
IMPORTING
RETURN =
KEY =
ENDLOOP.
if sy-subrc = 0.
write:/ 'SY-subrc is zero'.
write:/ ' Rows modified = ', sy-dbcnt.
else.
write:/ 'No Record(s) updated'.
endif.
commit work.
WRITE: / 'Updated Records in the Internal Table IT_PA2001'.
SELECT pernr sprps begda endda FROM PA2001 INTO CORRESPONDING FIELDS OF TABLE it_pa2001
WHERE begda BETWEEN date AND sy-datum..
LOOP AT it_pa2001 INTO wa_pa2001.
WRITE:/ wa_pa2001-pernr, wa_pa2001-sprps, wa_pa2001-begda, wa_pa2001-endda.
ENDLOOP.Thanks Kiran.
But I need to change this field as we need to lock the records, as soon as the employee fills his/her time sheets which will be sent for HR Payroll, later on.
When I am updating directly the field the database table PA2001, its not updating but for table PA2002, only few records are being updated.
Is there any other alternative for this problem?
Pls reply.
Thanks,
Harish -
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... -
Concatenate primary key in trx SE11
Hello.
I have create a z table in trx SE11, it has two field
document -> char 4
name -> char 20
and i want to create a concatenate primary key with this two fields
then i check the two fields with the check button and then i activate.
And the Initial Values check buttons activates automatically
After that i go to de SE16 trx and press the button new entries
and y put this for example
document name
1 paul
1 charles
When i save i have the follow error
"an entry already exist with the same key"
My question is:
How can i create a concatenate primary key ??
What i am doing wrong ?
Thank you very much !1 paul
1 charles
When i save i have the follow error
"an entry already exist with the same key"
cause u have made the first field as check in the table.
My question is:
How can i create a concatenate primary key ??
not sure what this concatenate key is but the next option for u is to check the second key field as well , save+activate the table .
so u will have two key fields in the table .
i hope that what you are looking for.
try and let me know if the same error pops up to you . -
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 ',' . -
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
-
TS1702 Lost shortcuts used in pages on iPad, any ideas?
After using Pages for some time, used keyboard shortcuts, ie type trc and auto expands to. The remaining contents of the room to include; They are still showing on keyboard shortcut list on iPad Any help would be gratefully received
-
How do you set a photo with contacts?
What size and format does the picture have to be to set it with the contact info?
-
Tired of wasting blank cd's.
No matter what I do (changing formats or speeds etc) burned CD-R's (downloaded albums from iTunes) won't play in my car or mini hifi. I have looked at the various suggestions and am about to resort to burning from windows laptop rather than my Mac.
-
Adobe Flash-Process closes after starting
So my problem is that I can not even run Adobe Flash. I downloaded the trialversion and I installed it too but after running the Flash.exe it closes immediately without any error message. I'm using WinXp SP3. What could be the problem?
-
ASDM cannot be loaded. ver 6.1
Hi all, Previously the ASDM on my XP Prof PC is working fine .. But some how this 2 days. The ASDM got error and the message is as below:- "ASDM cannot be loaded. CLick ok to exit ASDM. Unconnected sockets not implemented" Any advise ?