Modify ztable from internal table
Hi,
I have a Ztable in which i have 4 diff fields....1 2 3 4
and an internal table in whch i have same number of fields...
Internal table :
1 2 3 4
a w x 9
a w x 10
a w x 11
a w x 13
a w x 12
When I am using Modify it only appends last record into ztable as below:
Ztable : 1 2 3 4
a w x 12
Internal table has 6 records and z table should be appended with 6 records too...
if varid-report = 'ZFINRR1001' and
varid-VARIANT = 'CITI - ZBA' or
varid-VARIANT = 'WACHOVIA - ZBA'.
Modify ZV12_SWEEP from t_data_new.
endif.
Any suggestions will be aprreciated!
Regards,
Kittu
>
Kittu wrote:
> When I am using Modify it only appends last record into ztable
>
> Modify ZV12_SWEEP from t_data_new.
Hi,
You only get last record appended because your MODIFY statement uses t_data_new as a working area and not as a table.
To append the content of your internal table, use the FROM TABLE option as below :
MODIFY zv12_sweep FROM TABLE t_data_new.
Regards.
Nicolas
Similar Messages
-
I need insert /update/modify ztable from internal table or work area
I have one simple problem.
TYPES: BEGIN OF t_account,
acc_no LIKE zztaccountheader-acc_no,
cust_id LIKE zztaccountheader-cust_id,
acc_type LIKE zztaccountheader-acc_type,
od_option LIKE zztaccountheader-od_option,
od_limit LIKE zztaccountheader-od_limit,
od_issue_date LIKE zztaccountheader-od_issue_date,
END OF t_account.
data: lwa_account TYPE t_account,
li_account TYPE STANDARD TABLE OF t_account,
bu scerrin i am inputing data :
i want modify updare or insert record into ztable by work area i put following thing
MOVE : zztaccountheader-acc_no TO lwa_account-acc_no,
zztcustomer-cust_id TO lwa_account-cust_id,
zztaccountheader-acc_type TO lwa_account-acc_type,
zztaccountheader-od_option TO lwa_account-od_option,
zztaccountheader-od_limit TO lwa_account-od_limit,
zztaccountheader-od_issue_date TO lwa_account-od_issue_date.
INSERT zztaccountheader CLIENT SPECIFIED FROM lwa_account .
CLEAR lwa_account.
ENDIF.
i am etting error
The type of the database table and work area (or internal table)
"LWA_ACCOUNT" are not Unicode convertible.
please solve ithi,
decalre like this.
tables : zztaccountheader.
data : t_account like zztaccountheader occurs 0 with header line.
data: lwa_account TYPE t_account,
li_account TYPE STANDARD TABLE OF t_account,
MOVE : zztaccountheader-acc_no TO lwa_account-acc_no,
zztcustomer-cust_id TO lwa_account-cust_id,
zztaccountheader-acc_type TO lwa_account-acc_type,
zztaccountheader-od_option TO lwa_account-od_option,
zztaccountheader-od_limit TO lwa_account-od_limit,
zztaccountheader-od_issue_date TO lwa_account-od_issue_date.
INSERT zztaccountheader CLIENT SPECIFIED FROM lwa_account .
CLEAR lwa_account.
ENDIF.
rgss
anver
if hlped mark points -
Update ztable from internal table
I want to update the Ztable from internal table datas.
what is the syntax to update.
Its urgent send with coding example is betterHi
PARAMETERS: p_carrid TYPE sflight-carrid,
percent(1) TYPE p DECIMALS 0.
DATA sflight_tab TYPE TABLE OF sflight.
FIELD-SYMBOLS <sflight> TYPE sflight.
SELECT *
FROM sflight
INTO TABLE sflight_tab
WHERE carrid = p_carrid AND
fldate = sy-datum.
IF sy-subrc = 0.
LOOP AT sflight_tab ASSIGNING <sflight>.
<sflight>-price =
<sflight>-price * ( 1 - percent / 100 ).
ENDLOOP.
ENDIF.
<b>UPDATE sflight FROM TABLE sflight_tab.</b>
Thanks
Vijay
PLZ reward points if helpful -
Insert or Modify statement from internal table to database table
Hi All,
I have three tables wakh, wrf and wakp. I have an internal table with 5 columns col1, col2, col3, col4 and col5.
The value in Col1 is my article no and the articleno. is in the table wakh. The value in col2 is my ccode and it is in the table wrf. The rest three columns col3, col4 and col5 are unit, qty and price and they are in the wakp table. Now when my articleno is equal to ccode I need to update the col3, col4 and col5 values in the wakp. wakp has around 20 columns.
Can anyone of you guys please give me the code for this issue. Your help is highly appreciated and thanks for all for your time.
Cheers,
ChengHi Rob,
let me explain you the whole process what i am trying to do. I have a screen where there are 3 fields. In my first field I have a promoiton no. As soon as the user enters the promotion no. its description will be populated in my second field. If the promotion is not maintained then it will throw an error. In my third field User will upload an excel sheet which has 5 columns articleno, colorcode, salesunit, qty, mdprice. Here articleno is coming from wakh and colorcode is in wrf_charval table and the rest three fields are coming from wakp table. So for the article no. which is in col1. and for its corresponding colorcode which is in col3 i need to update col3, col4, col5 values.
With my below code I am able to upload the excel into internal table and display it. So instead of displaying I need to update in the database. Can you please let me know how I need to attach the function module within my code and update accordingly.
REPORT ZTest.
tables : wakh, wakt.
Parameter: PromoID type wakh-aktnr, PromoDec type wakt-aktkt, p_file LIKE rlgrap-filename
DEFAULT 'c:\test.xls' OBLIGATORY. " File Name
*FileName type string.
*file_nm type localfile.
TYPES: BEGIN OF t_datatab,
col1(25) TYPE c,
col2(30) TYPE c,
col3(30) TYPE c,
col4(30) TYPE c,
col5(30) TYPE c,
END OF t_datatab.
DATA: it_datatab TYPE STANDARD TABLE OF t_datatab INITIAL SIZE 0,
wa_datatab TYPE t_datatab.
Data : p_table type t_datatab occurs 0 with header line.
DATA : gd_scol TYPE i VALUE '1',
gd_srow TYPE i VALUE '2',
gd_ecol TYPE i VALUE '5',
gd_erow TYPE i VALUE '65536'.
DATA: it_tab TYPE filetable,
gd_subrc TYPE i.
field-symbols : <fs>.
AT selection-screen on PromoID.
select single * from wakh where aktnr = PromoID.
if sy-subrc EQ 0.
select aktkt from wakt into PromoDec where aktnr eq PromoID.
endselect.
else.
message A000(ZI) with 'Promotion ID is not Maintained.'.
endif.
*Title : Excel Uploading
*Selection screen definition
*SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
*PARAMETERS: p_file LIKE rlgrap-filename
DEFAULT 'c:\test.xls' OBLIGATORY. " File Name
*SELECTION-SCREEN END OF BLOCK b1.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
REFRESH: it_tab.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
window_title = 'Select File'
default_filename = '*.xls'
multiselection = ' '
CHANGING
file_table = it_tab
rc = gd_subrc.
LOOP AT it_tab INTO p_file.
so_fpath-sign = 'I'.
so_fpath-option = 'EQ'.
append so_fpath.
ENDLOOP.
START-OF-SELECTION.
PERFORM upload_excel_file TABLES it_datatab
USING p_file
gd_scol
gd_srow
gd_ecol
gd_erow.
END-OF-SELECTION.
END-OF-SELECTION.
LOOP AT it_datatab INTO wa_datatab.
WRITE:/ wa_datatab-col1,
wa_datatab-col2,
wa_datatab-col3,
wa_datatab-col4,
wa_datatab-col5.
ENDLOOP.
*& Form UPLOAD_EXCEL_FILE
upload excel spreadsheet into internal table
-->P_TABLE Table to return excel data into
-->P_FILE file name and path
-->P_SCOL start column
-->P_SROW start row
-->P_ECOL end column
-->P_EROW end row
FORM upload_excel_file TABLES p_table
USING p_file
p_scol
p_srow
p_ecol
p_erow.
DATA : lt_intern TYPE kcde_cells OCCURS 0 WITH HEADER LINE.
Has the following format:
Row number | Colum Number | Value
i.e. 1 1 Name1
2 1 Joe
DATA : ld_index TYPE i.
Note: Alternative function module - 'ALSM_EXCEL_TO_INTERNAL_TABLE'
CALL FUNCTION 'KCD_EXCEL_OLE_TO_INT_CONVERT'
EXPORTING
filename = p_file
i_begin_col = p_scol
i_begin_row = p_srow
i_end_col = p_ecol
i_end_row = p_erow
TABLES
intern = LT_INTERN
EXCEPTIONS
inconsistent_parameters = 1
upload_ole = 2
OTHERS = 3.
IF sy-subrc <> 0.
FORMAT COLOR COL_BACKGROUND INTENSIFIED.
WRITE:/ 'Error Uploading file'.
EXIT.
ENDIF.
IF lt_intern[] IS INITIAL.
FORMAT COLOR COL_BACKGROUND INTENSIFIED.
WRITE:/ 'No Data Uploaded'.
EXIT.
ELSE.
SORT lt_intern BY row col.
LOOP AT lt_intern.
MOVE lt_intern-col TO ld_index.
assign component ld_index of structure
p_table to <fs>.
move : lt_intern-value to <fs>.
MOVE lt_intern-value TO p_table.
AT END OF row.
APPEND p_table.
CLEAR p_table.
ENDAT.
ENDLOOP.
ENDIF.
ENDFORM.
Thanks for your valuable time.
Cheng -
Regarding modifying database from internal table
Hi ABAP Experts,
I am facing an issue regarding modifying DB table from itab.
All the records of itab are not getting reflected in DB table using Modify statement.
Syntax is as follows -
Locking DB table using enque FM
MODIFY abc FROM TABLE i_abc.
Unlocking DB table using deques FM
Please suggest what could be wrong with this. Helpful suggestion will be appreciated.
Thanks in adv,
AkashHi,
First Delete entries from the table(hope it is a custom table),
for example
DELETE FROM <DatabaseTable name> WHERE <primarykey = 'somevalue'>.
'After deleting those records.....then use insert statement
IF sy-subrc = 0.
INSERT <DatabaseTable name> FROM TABLE <InternalTable name> ACCEPTING DUPLICATE KEYS.
ENDIF.
Thanks & REgards -
Modify database table from internal table
Hi All,
I need to update database table from internal table which is having around 30000 records.
I am using MODIFY tabname FROM TABLE int_tabname...
Using this statement, I can modify the databse records very well. But user has some additional requirement.
He wants that the table should be modified from the internal table and after modification we should have the erroneous records to be displayed if any.
e.g. if 1500 records out of 30000 are erroneous then only 28500 records should be updated and 1500 records should be displayed as erroneous records so that the user can correct them and use them again for executing the program.
Is there any FM which imports the database table name and internal table, modifies the database and exports an internal tanle with erroneous records?
Any help will be appriciated,
Regards,
NehaHi
modifying datbase table useing internal table
<b>advises</b> before updating this datbase table plz lock that table to avoid incosistency
write the logic for modifying
Modify the database table as per new dunning procedure
MODIFY fkkvkp FROM TABLE lt_fkkvkp .
and finally unlock the table
<b>example</b>
*To lock table for further operations
constants: lc_tabname TYPE rstable-tabname VALUE 'FKKVKP' . "FKKVKP
CALL FUNCTION 'ENQUEUE_E_TABLE'
EXPORTING
tabname = lc_tabname
EXCEPTIONS
foreign_lock = 1
system_failure = 2
OTHERS = 3.
IF sy-subrc EQ 0.
To fetch all the contract accounts for customers of the segment
Households/SME.
PERFORM fetch_contract_accounts using lc_tabname .
ENDIF. " IF sy-subrc EQ 0.
*wrote the logic
Modify the database table as per new dunning procedure from internal table
MODIFY fkkvkp FROM TABLE lt_fkkvkp .
*unlock the tbale
CALL FUNCTION 'DEQUEUE_E_TABLE'
EXPORTING
TABNAME = uc_tabname .
<b>Reward if usefull</b> -
Inserting records from internal table to database table
Hi all,
i want to insert records from internal table to zDatabase table, can u plz guide me which statement is better in performance to insert the records.
1) insert one by one record from internal table
loop at itab.
insert ztable from wa.
endloop.
2) insert total records at a time
INSERT <dbtabname> CLIENT SPECIFIED FROM TABLE itab.
or let me know if any other statement is there with high performance.
i internal table contains nearly 40000 records.
thanks.Hi,
Insert the entire table at atime rather than a record so as to increase the performance.
you can use INSERT <dbtabname> CLIENT SPECIFIED FROM TABLE itab.
or
MODIFY ZPRODUCT FROM TABLE GI_AFPO.
Regards,
Raj. -
Can not insert or update [TABLE] from internal table in method
I've faced a problem with OO abap. I've tried to insert into [ TABLE ] from internal table, but i've got error msg after i compiled.
"An explicit work area is necessary in the OO context. Use "INSERT wa INTO [TABLE] itab""
After i changed to loop in work area and INSERT INTO [TABLE] VALUES gw_data., everything is fine, can compile and run.
This is error code.
METHOD set_data_to_table.
REFRESH gi_data.
CLEAR gi_data.
IF gi_file[] IS NOT INITIAL.
* Set data for modify table
LOOP AT gi_file INTO gw_file.
MOVE-CORRESPONDING gw_file TO gw_data.
me->conversion_input( EXPORTING im_vendor = gw_data-vendor
CHANGING ch_vendor = gw_data-vendor ).
APPEND gw_data TO gi_data.
ENDLOOP.
INSERT [TABLE] FROM TABLE gi_data.
* LOOP AT gi_data INTO gw_data.
* INSERT INTO [TABLE] VALUES gw_data.
* IF sy-subrc = 0.
* COMMIT WORK.
* ELSE.
* ROLLBACK WORK.
* ENDIF.
* ENDLOOP.
ELSE.
MESSAGE 'No data found' TYPE 'I'.
ENDIF.
ENDMETHOD. "set_data_to_tableHi Matthew,
I think there is no difference in database insert between OO and non-OO.
The correct syntax according to ECC600 online documentation is
[Inserting Several Lines|http://help.sap.com/saphelp_erp2005vp/helpdata/en/fc/eb3a6d358411d1829f0000e829fbfe/content.htm]
To insert several lines into a database table, use the following:
INSERT target FROM TABLE itab \[ACCEPTING DUPLICATE KEYS].
This writes all lines of the internal table itabto the database table in one single operation. If one or more lines cannot be inserted because the database already contains a line with the same primary key, a runtime error occurs. You can prevent the runtime error occurring by using the addition ACCEPTING DUPLICATE KEYS.
Whenever you want to insert more than one line into a database table, it is more efficient to work with an internal table than to insert the lines one by one.
I think the syntax
INSERT my_dbtable FROM TABLE gi_data.
should work, your suggestion may lead to syntax error.
Regards,
Clemens -
Problem in modifying the main internal table gt_data
Hello i have written code for modifying the main internal table. i have read data from ausp table and put into the internal table gt_ausp. now i want to modify my main table GT-DATA with gt_ausp. i am not able to do this.
LOOP AT gt_data INTO ls_list.
lt_temp-objek = ls_list-matnr.
APPEND lt_temp. " 특성값 발췌용도로 저장
APPEND ls_list TO lt_work. " 핵심작업용도로 저장
ENDLOOP.
DESCRIBE TABLE lt_temp.
IF sy-tfill EQ 0.
pv_flg = 'X'.
EXIT.
ENDIF.
Get 제품인증(플랜트별).....
DESCRIBE TABLE lt_cetino_tp.
플랜트 자재번호
카타로그-인증 코드그룹-인증 인증코드
Certi. No.
Get 자재별 특성값..........
오브젝트 특성이름 내부특성 내부카운터 특성값
SELECT aobjek batnam aatinn aatzhl a~atwrt
INTO CORRESPONDING FIELDS OF TABLE lt_ausp_tp
FROM ausp AS a INNER JOIN cabn AS b
ON aatinn = batinn
FOR ALL ENTRIES IN lt_temp
WHERE a~objek EQ lt_temp-objek " 오브젝트키(자재번호)
AND a~klart EQ '001' " 클래스유형
AND a~atzhl EQ '001' " 특성값카운터(최종건만 존재)
자재특성 변경시 변경됨
AND b~adzhl EQ '0000'.
IF sy-subrc EQ 0.
DELETE ADJACENT DUPLICATES FROM lt_ausp_tp.
lt_ausp[] = lt_ausp_tp[].
lt_ausp_tp2[] = lt_ausp_tp[].
DELETE ADJACENT DUPLICATES FROM lt_ausp_tp2.
Get 특성내역
내부특성 " 내부카운터
특성값 특성값내역
SELECT aatinn " aatzhl
aatwrt batwtb
INTO CORRESPONDING FIELDS OF TABLE lt_cawn
FROM cawn AS a INNER JOIN cawnt AS b
ON aatinn = batinn AND
aatzhl = batzhl AND
aadzhl = badzhl
FOR ALL ENTRIES IN lt_ausp_tp2
WHERE a~atinn EQ lt_ausp_tp2-atinn " 내부특성
AND b~spras EQ sy-langu.
ENDIF.
SORT lt_work BY matnr .
BREAK-POINT.
LOOP AT lt_work INTO ls_list.
특성내역
READ TABLE lt_ausp WITH TABLE KEY objek = ls_list-matnr
atnam = 'SECTION_WIDTH'.
수출자재가 아닌 것은 제외
LS_LIST-SECTION_WIDTH = LT_AUSP-ATWRT.
MODIFY TABLE GT_DATA FROM LS_LIST TRANSPORTING SECTION_WIDTH.Hi,
Question before: why dont you just use the std.API for reading the classification data?
e.g. "BAPI_OBJCL_GETDETAIL"
Second: a DELETE DELETE ADJACENT DUPLICATES works only only sorted tables.
Doing this after a select will only succeed randomly depending on the buffers of your data based below.
( 90% chance if it is an oracle system)
To your question:
Just replace your LOOP AT gt_data into ls_list
by a LOOP AT gt_data ASSIGNING <current_list_record>.
then you can access the fields directly:
<current_list_record>-SECTION_WIDTH = LT_AUSP-ATWRT.
Cause of your issue:
"MODIFY" needs a key to to find the record to be updated.
If your gt_data ist referencing a DDIC table type with a key or a local type with a key
it has no chance to do it.
Hope that helps.
br, -
How to update Records from Internal table to u2018Zu2019 table?
Hi Friends,
How to update Records from Internal table to u2018Zu2019 table.
I have records in Internal table , that records want to update on u2018Zmarau2019 Table.
( my internal table & u2018 Zu2019 table structures are same.)
Thanking you.
Regards,
SubashHi,
loop at internal table.
modify <Z- table > from values < internal table Workarea>.
if sy-subrc = 0.
COMMIT work.
else.
ROLLBACK waork.
endif.
endloop.
or
UPDATE <Z- table > from table < internal table Workarea>.
if sy-subrc = 0.
COMMIT work.
else.
ROLLBACK waork.
endif.
Prabhudas -
Update ztable from database table directly
hi all,
can u tell me the possible ways to update a ztable from database table directly.
i mean is there anyway to update ztable whenever entry is created in database table .
i dont want to update using insert,modify statements.
points will be rewarded to all hlpful answers.A slightly dirty solution:
Use SAP functions for reading from CDHEADER and CDPOS tables [with enough filters such that you extract minimum records possible] to read changes to MARA table fields since last run of your program. Use this information to update your ZTABLE. I would recommend having a table maintainance generator on ZTABLE. The actual update should be by a BDC by calling transaction SM30 for ZTABLE maintainance. Now the program may be set up as a batch job running 1ce an hour. You get updates to the extent of 1 hour latency.
Alternatively, you may look if an opportunistic BADI / user Exit is there alongside MM01/02 transactions - assuming the latter are the only ones updating MARA. In this BADI you may write the code to update ZTABLE- again, look to do it by BDC call transaction sm30 to maintain ZTable. To lighten up the code -load on BADI you may simply raise a custom event and move on. You will configure a job that runs your program when that particular event is raised. This will need the 'burden' of figuring out the changes, though.
An elegant way would be to fire a MATMAS fIDOC for every change to Material, capture that and turn back the changes to ZTABLE. This will facilitate the delta load. -
Fetch the values from internal table inside an internal table (urgent!!)
data : BEGIN OF PITB2_ZLINFO occurs 0,
BEGDA LIKE SY-DATUM,
ENDDA LIKE SY-DATUM,
PABRJ(4) TYPE N, "Payroll Year
PABRP(2) TYPE N, "Pay. Period
ZL LIKE PC2BF OCCURS 0,
END OF PITB2_ZLINFO.
I have a internal table like this,
How to Fetch the values from internal table inside an internal table.
Kindly Help me on this..
Regards,
Ram.Hi,
Try this....
Loop at PITB2_ZLINF0.
Loop at PITB2_ZLINF0-ZL.
endloop.
Endloop.
Thanks...
Preetham S -
How to send data from internal table to the shared folder in ABAP
Hi experts,
My requirement is to transfer data from a file to shared folder. i just did reading data from a file to a internal table. Now i want to send this internal table data into a shared folder which is "
xxx\y\z....".
I do not have any idea on how to send data from internal table to the shared folder path.
can anybody please help me out how to do this?
Thanks & Regards
Sireesha.Where that folder is located, its on presentation server i.e. desktop or application server.
If its on presentation server, use FM GUI_UPLOAD.
If its on application server, then use DATASET functions. Have a look at below link.
[File Handling in ABAP|http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3ca6358411d1829f0000e829fbfe/frameset.htm]
I hope it helps.
Thanks,
Vibha
Please mark all the useful answers -
To get recent timestamp records from internal table
hi all,
i have one requirment
i'm storing error messages in one table while creating a sales order basing on timestamp
which is of this format yyyy-mm-dd hh:mm:ss (random Number)
if i want to see the error messages left i'm getting all the error messages displayed
for example i have created a sales order
i got 10 errors displayed
i have rectified 5 errors ... if i again display error messages the 10 errors + the 5 errors is getting displayed
i want to display the 5 error messages only not the previous messages from internal table
basing on timestamp current one has to displayed remaining has to deleted from internal table.I thought we used Sales Order Incompletion process for this.... but, if you're recreating the errors list every time you save with a create or change transaction then, at save, delete all rows in your error table for this document. Then get your errors and update your db table from your current errors table. From this viewpoint, the timestamp is not relevant.
-
Create XML file from internal table and vise a versa
Hi Friends,
I have requirement to create an XML string from internal table data and also read XML string data to internal table.
Can anybody tell are there any Function Modules or methods existing for this?
Thanks.
Krishna Yerram.1. Write XSLT program. T.code XSLT . e.g. XSLT name "ZTRANS".
2. Write ABAP program
Which includes declaration of internal tables
that you need "IT_DATA".
Upload XML data to an internal table "IT_XML "
use below statement to convert XML to internal table.
Call transformation ZTRANS
source XML IT_XML
result IT_DATA.
Maybe you are looking for
-
Error 1935 when downloading Adobe Elements 11.
I keep getting the error 1935 message when I am downloading Adobe Elements 11 program.
-
Geturl or ExternalInterface does not work in Firefox 2.0
This works in IE7: on (release) { var callJas:String = 'javascript:abrir_faleconnosco()'; getURL(callJas); But when using the same html with flash in Firefox, the Flash never makes the call to the javascript function. I tried also with button_1.onRel
-
Adobe Flash Player Problem (Jelly Bean)
Hello, I'm from Mexico City and the update was released on 02/04/13. I update but there was a message that says a problem with Adobe Flash Player before upgrading. When the update finished, I looked in the Adobe applications and not find it. With Ope
-
I don't want Nokia DAB Radio - stop telling me abo...
Is there a way to permanently stop being advised of particular updates? I don't have a DAB headset and have no intention of getting one. I don't want to install the DAB Radio on my N8 but software update clearly wants me to. Most software updates giv
-
REUSE_ALV_GRID_DISPLAY --- on - APO /SCM 4.10
Hi , Though my requirement is simple, but not getting the desired output from 'REUSE_ALV_GRID_DISPLAY' Function. I'm using this function for data display in Grid layout. but the default menu bar is get disturbed, though i have not set any PF-STATUS