Comparing headerlines of internal tables
Hi abapers,
I have 2 internal table IT1 & IT2 with header line.
In a loop i take values of IT1, one by one, to its header line and compare it with the header line of IT2.
How can i compare header lines of two internal table?
Explanation with a example will sound good and clear.
Thanks in advance
Regards,
Lakshminarasimhan.N
Hi,
try like below...
loop at one table,read the other one.....if sy-subrc is 0 den dat line is in both de tables.....
DATA : it1 TYPE TABLE OF mara WITH HEADER LINE,
it2 TYPE TABLE OF mara WITH HEADER LINE.
SELECT * FROM mara UP TO 5 ROWS INTO TABLE it1.
SELECT * FROM mara UP TO 10 ROWS INTO TABLE it2.
LOOP AT it1.
READ TABLE it2 WITH KEY matnr = it1-matnr.
IF sy-subrc IS INITIAL.
WRITE : / it2-matnr,' exists in both the tables..'.
ENDIF.
ENDLOOP.
Cheers,
jose.
Similar Messages
-
Comparing each value of two internal tables
HI everybody,
i have two internal tables itab1 and itab2 same structure
both r having four fields each and field with values
now i need to compare the two internal tables
and if every value of itab1 matches itab2
then i have to write one select quirie for the following given description
compare past and current shipping point
compare internal_table2 and internal_table3
if entry in internal_table2 and internal table3 match
variable_tknum = internal_table2-tknum
endif.
for each entry that matches:
select vlabdata into zi_vlabdata from vlbl where vbeln = variable_tknum and vlbl-vlabtyp = 'ZIBOOKNO'.
plz give me solution for this
thanks
hridhayanjili.sort : ITAB1 by f1,f2,f3,f4,
ITAB2 by f1,f2,f3,f4.
LOOP AT ITAB1.
READ TABLE ITAB2 WITH KEY F1 = ITAB1-F1
F2 = ITAB1-F2
F3 = ITAB1-F3
F4 = ITAB1-F4 BINARY SEARCH.
IF SY-SUBRC = 0.
*--all the fields of ITAB1 and ITAB2 are matching .
*--write your logic here
ELSE.
*--ITAB1 and ITAB2 records are not matching.
ENDIF.
ENDLOOP.
Regards
Srikanth
Message was edited by: Srikanth Kidambi -
Hi all,
I have 2 internal tables containing records from 2 different database tables.
How can i compare the 2 internal tables and produce result that the record exists in one table
but not in the second table.
Thanks,
Reddy.Re: Comparing Internal Tables
loop at table1.
read table table2 where pmkey = pmkey2.
IF SY-SUBRC = 0.
delete table1.
ENDIF.
endloop.
The above code removes the data from new table... -
How to compare data between two tables?
Hi,
My team is trying to develop a SAP data migration tool (DMT) using ABAP.
One of the functionalities in the DMT is to validate the data in the staging area against the loaded SAP data.
The tables in the stagin area are customer tables (i.e. user-defined tables starting with Y, Z).
How do I compare the data in the staging area against data that are loaded into SAP tables? Are there some built-in SAP functions to do this? Or, are there some better ways of doing this (e.g. instead of comparing against data in the SAP tables, we compare with some INTERNAL tables)?
Any help would be greatly appreciated, thanks!Hi Kian,
Use <b>SCMP</b> transaction to compare data between two tables and you can not use this for comparing internal tables.
Thanks,
Vinay -
Comapare internal tables which are in tree format
Hi guys,
Consider internal table
level | material-no.|quantity
1 | mat-1 | 10
2 | mat-5 | 1
3 | mat-2 | 1
3 | mat-4 | 12
2 | mat-12 | 11
3 | mat-15 | 12
................................>mat1 ends here..it contains mat5 and mat 12 which in turn contain
.......................mat2 & 4 and mat 15 respectively.
1 | mat-8 | 1
2 | mat-6 | 3
2 | mat-100 | 5
......................................>mat 8 ends here
1 | mat -6 | 13
.......................................>mat 6 ends here
This data is in one internal table, here there are 3 main materials (1,8,6) which are in-turn made of other materials.
material at level 1 is made of materials at level 2
and in-turn materials at level2 are made up of materials at level3 .
Now same material can exist at different levels ...
What would be the efficient way to compare two such internal tables and comparisons are done wrt quantity but level and hierarchy at which material exits matters and
comparison shuld be done at each level .
if both materials are in same hierarchy in both tables but diff in quantity then they are unequal .
if both materials are in same hierarchy in both tables and equal in quantity then they are equal .
if that material exist in one but doesnot exist in other table in similar hierarchy then its rendered as
not found.
many thanks in advance.Hi Anurag,
Thanks for the reply but the number of levels is not always 3(it completely depends on data) .I came up with one solution --what I have done is , created one more column <b>HPATH</b> in the internal table and kept hierarchy relationship ..i.e
level| material| qty | HPATH(hierarchy path)
1 | mat-1 | 10 | mat-1
2 | mat-5 | 1 | mat-1 2 mat-5
3 | mat-2 | 1 | mat-1 2 mat-5 3 mat-2
3 | mat-4 | 12 | mat-1 2 mat-5 3 mat-4
2 | mat-12 | 11 | mat-1 2 mat-12
3 | mat-15 | 12 | mat-1 2 mat-12 3 mat-15
1 | mat-8 | 1 | mat-8
2 | mat-6 | 3 | mat-8 2 mat-6
2 | mat-100 | 5 | mat-8 2 mat-100
2 and 3 are the path seperates..which indicate the level..
Thus I get key as unique for each material depending on its position in heirarchy ..
Then I looped wrt one table and read data form other table with HPATH as key and compared it .
This solved it...
The number of levels doesnot matter in this solution...
Thanks once again for replying to my post. I would be to happy to put up the code if u want.. -
Hi Gurus,
I want to print sum of a particular coloumn in dynamic internal table,
But in Field symbold use char type so i cant able to print sum.
help me to solve this problem.
Regards,
Bhuvana.Hi
Herwith i attach my code.
*& Report ZFR133_TELECAST_REVENUE *
REPORT zfr133_telecast_revenue .
MODULE xxxxxxxx. *
Objective :.......................................... *
Program : Updates Tables ( ) Downloads data ( ) *
Outputs List ( ) *
Technical Spec No ............... *
Date Created 17/09/2008 *
Author J.Bhuvaneswari *
Location SUN TV / Chennai *
LDB ..... *
External Dependencies *
Amendment History *
Who Change ID Reason *
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ *
XXXXXXXXX AADDMMYYYY Where XXXX = Developers Name................. *
AA- Developers Initial ................................ *
Includes *
*INCLUDE : *
Tables *
TABLES : t001, bkpf, csks, bseg, cskt.
Types Begin with TY_ *
TYPES : BEGIN OF ty_bkpf,
bukrs LIKE bkpf-bukrs,
belnr LIKE bkpf-belnr,
gjahr LIKE bkpf-gjahr,
monat LIKE bkpf-monat,
stblg LIKE bkpf-stblg,
END OF ty_bkpf,
BEGIN OF ty_bseg,
bukrs LIKE bseg-bukrs,
gjahr LIKE bseg-gjahr,
belnr LIKE bseg-belnr,
shkzg LIKE bseg-shkzg,
dmbtr LIKE bseg-dmbtr,
kostl LIKE bseg-kostl,
hkont LIKE bseg-hkont,
END OF ty_bseg,
BEGIN OF ty_cskt,
kostl LIKE cskt-kostl,
ltext LIKE cskt-ltext,
END OF ty_cskt,
BEGIN OF ty_temp,
belnr LIKE bseg-belnr,
monat LIKE bkpf-monat,
kostl LIKE cskt-kostl,
ltext LIKE cskt-ltext,
shkzg LIKE bseg-shkzg,
dmbtr LIKE bseg-dmbtr,
END OF ty_temp.
DATA: BEGIN OF ty_stru OCCURS 0,
kostl LIKE cskt-kostl,
monat LIKE bkpf-monat,
dmbtr LIKE bseg-dmbtr,
END OF ty_stru.
Constants Begin with C_ *
*CONSTANTS: *
Data Begin with W_ *
DATA : w_amt LIKE bseg-dmbtr,
w_var TYPE string,
w_text TYPE string,
w_value TYPE i,
w_cnt TYPE i VALUE 1,
w_mon TYPE month,
okcode TYPE sy-ucomm.
Infotypes ( HR Module Specific) *
*INFOTYPES : *
Internal tables Begin with IT_ *
DATA : it_bkpf TYPE TABLE OF ty_bkpf,
it_bseg TYPE TABLE OF ty_bseg,
it_cskt TYPE TABLE OF ty_cskt,
it_temp TYPE TABLE OF ty_temp,
it_tmp1 TYPE TABLE OF ty_temp,
it_tmp2 TYPE TABLE OF ty_temp,
it_ccen TYPE TABLE OF ty_temp,
it_monat TYPE TABLE OF ty_temp.
DATA : xfc TYPE lvc_s_fcat,
ifc TYPE lvc_t_fcat,
ty_lay TYPE lvc_s_layo,
dy_table TYPE REF TO data,
dy_line TYPE REF TO data.
DATA : cl TYPE REF TO cl_gui_custom_container,
cl_alv TYPE REF TO cl_gui_alv_grid.
DATA : wa_bkpf TYPE ty_bkpf,
wa_bseg TYPE ty_bseg,
wa_cskt TYPE ty_cskt,
wa_temp TYPE ty_temp,
wa_tmp1 TYPE ty_temp,
wa_tmp2 TYPE ty_temp,
wa_ccen TYPE ty_temp,
wa_monat TYPE ty_temp,
wa_month TYPE t247.
Field Symbols Begin with FS_ *
*FIELD-SYMBOLS: *
FIELD-SYMBOLS: .
Insert *
*INSERT : *
Select Options Begin with SO_ *
SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
PARAMETERS : pr_bukrs LIKE t001-bukrs OBLIGATORY,
pr_gjahr LIKE bkpf-gjahr OBLIGATORY.
SELECT-OPTIONS : so_monat FOR bkpf-monat OBLIGATORY,
so_kostl FOR bseg-kostl OBLIGATORY,
so_hkont FOR bseg-hkont OBLIGATORY.
SELECTION-SCREEN END OF BLOCK blk1.
Parameters Begin with PR_ *
*PARAMETERS : *
Initialisation *
*INITIALIZATION.
At selection-screen *
*AT SELECTION-SCREEN.
S T A R T O F S E L E C T I O N *
START-OF-SELECTION.
******Select data from Header Table.
SELECT bukrs gjahr belnr monat stblg
FROM bkpf INTO CORRESPONDING FIELDS OF TABLE it_bkpf
WHERE bukrs = pr_bukrs AND
gjahr = pr_gjahr AND
monat IN so_monat AND
stblg = ' '.
******Select data from Item Table
IF it_bkpf IS NOT INITIAL.
SELECT bukrs gjahr belnr shkzg dmbtr kostl hkont
FROM bseg INTO CORRESPONDING FIELDS OF TABLE it_bseg
FOR ALL ENTRIES IN it_bkpf
WHERE bukrs = it_bkpf-bukrs AND
gjahr = it_bkpf-gjahr AND
belnr = it_bkpf-belnr AND
kostl IN so_kostl AND
hkont IN so_hkont.
ENDIF.
******Select Cost center text
SELECT kostl ltext
FROM cskt INTO CORRESPONDING FIELDS OF TABLE it_cskt
WHERE spras = 'EN' AND
kokrs = 'SUN1' AND
kostl IN so_kostl.
******Append data in temporary table.
LOOP AT it_bseg INTO wa_bseg.
READ TABLE it_bkpf INTO wa_bkpf WITH KEY belnr = wa_bseg-belnr.
IF sy-subrc = 0.
wa_temp-belnr = wa_bkpf-belnr.
wa_temp-monat = wa_bkpf-monat.
wa_temp-kostl = wa_bseg-kostl.
READ TABLE it_cskt INTO wa_cskt WITH KEY kostl = wa_bseg-kostl.
IF sy-subrc = 0.
wa_temp-ltext = wa_cskt-ltext.
ENDIF.
IF wa_bseg-shkzg = 'H'.
wa_temp-dmbtr = wa_bseg-dmbtr * -1.
ELSE.
wa_temp-dmbtr = wa_bseg-dmbtr.
ENDIF.
APPEND wa_temp TO it_temp.
ENDIF.
ENDLOOP.
SORT it_temp BY kostl monat.
******Internal Table of cost center without duplications.
it_ccen = it_temp.
DELETE ADJACENT DUPLICATES FROM it_ccen COMPARING kostl.
******Internal Table of fiscal period without duplications.
it_monat = it_temp.
SORT it_monat BY monat.
DELETE ADJACENT DUPLICATES FROM it_monat COMPARING monat.
PERFORM dynamic_table.
PERFORM data_upload_dynamic_table.
SET SCREEN 3000.
IF cl IS INITIAL.
CREATE OBJECT cl EXPORTING container_name = 'TC'.
CREATE OBJECT cl_alv EXPORTING i_parent = cl.
ENDIF.
CALL METHOD cl_alv->set_table_for_first_display
EXPORTING
i_structure_name = 'ZALIKP'
is_layout = ty_lay
CHANGING
it_outtab =
it_fieldcatalog = ifc.
*GET XX.
*END-OF-SELECTION.
E N D O F S E L E C T I O N *
At line selection *
*AT LINE-SELECTION.
User Command Processing *
*AT USER-COMMAND.
Top Of Page *
*TOP-OF-PAGE.
End Of Page *
*END-OF-PAGE.
*& Form DYNAMIC_TABLE
FORM dynamic_table .
PERFORM design_fieldcat USING 'KOSTL' 'BSEG' text-002 '10'.
PERFORM design_fieldcat USING 'LTEXT' 'CSKT' text-003 '30'.
LOOP AT it_monat INTO wa_monat.
CONCATENATE 'PE' wa_monat-monat INTO w_text.
w_mon = wa_monat-monat.
CALL FUNCTION 'IDWT_READ_MONTH_TEXT'
EXPORTING
langu = sy-langu
month = w_mon
IMPORTING
t247 = wa_month.
w_var = wa_monat-monat.
w_text = wa_month-ltx.
PERFORM design_fieldcat USING w_var 'BKPF' w_text '10'.
ENDLOOP.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = ifc
IMPORTING
ep_table = dy_table.
ASSIGN dy_table->* TO .
ENDFORM. " DYNAMIC_TABLE
*& Form DESIGN_FIELDCAT
FORM design_fieldcat USING value TYPE string
tab TYPE string
text TYPE string
length TYPE string.
xfc-fieldname = value.
xfc-tabname = tab.
xfc-reptext = text.
xfc-outputlen = length.
APPEND xfc TO ifc.
w_cnt = w_cnt + 1.
CLEAR xfc.
ENDFORM. " DESIGN_FIELDCAT
*& Form DATA_UPLOAD_DYNAMIC_TABLE
FORM data_upload_dynamic_table .
DATA : w_c(2) TYPE c,
w_c1(5) TYPE c,
w_c2(5) TYPE c.
CREATE DATA dy_line LIKE LINE OF .
CLEAR: wa_tmp2,w_amt.
ENDON.
ENDLOOP.
ENDLOOP.
ENDFORM. " DATA_UPLOAD_DYNAMIC_TABLE
*& Module STATUS_3000 OUTPUT
MODULE status_3000 OUTPUT.
SET PF-STATUS 'MENU'.
SET TITLEBAR 'TIT'.
ENDMODULE. " STATUS_3000 OUTPUT
*& Module USER_COMMAND_3000 INPUT
MODULE user_command_3000 INPUT.
CASE okcode.
WHEN 'BACK'." OR 'RW' OR '%EX'.
LEAVE PROGRAM.
CLEAR okcode.
ENDCASE.
ENDMODULE. " USER_COMMAND_3000 INPUT -
Regarding read and compare of internal table.
HI,
i want to read internal table based on key pernr.
suppose if we load the dec month data we want the last record of that month.
if we load march 2008 data we want todays record.
for this there are two fields datefrom and dateto.
how to compare thesse two fields in read statement.
regards,
swami.Hi,
Check this code
loop at itab.
endloop.
if month = december
read table itab with key sy-tabix = sy-dbcnt.
"above stmt will fetch the last record
elseif month = march
read table itab with key sy-tabix = 1.
"above stmt will fetch the first record.
endif.
Reward if helpful.
Regards. -
How to compare each row in an internal table
Hi,
Say I have an internal table with 3 fields in each row, num1, num2, num3, each type of integer i, now I want to get the maximum of num1, num2, num3 and put this maximum number into num4, may I know how can I do that? Also, if say I need to pull out this num4 and play around with it, sould I just loop it into my workarea of internal table and assign a variable for whatever that is in the work area? Thanks a lot!
Regards,
AnyiHi,
Inside a loop of the table compare each field like this:
loop at itab.
l_num4 = itab-num1.
if l_num4 < itab-num2. l_num4 = itab-num2. endif.
if l_num4 < itab-num3. l_num4 = itab-num3. endif.
Here you can play with the maximum number
itab-num4 = l_num4.
modify itab.
endloop.
You can also do the same using field-symbols (it's faster to assignations) :
loop at itab assigning <a>.
endloop.
Regards. -
What are the advantages using internal tables without headerline.
hi,
i have a doubt,please clarify.
data:itab like <databse table> occurs 0 with header line.
or
data:itab like <databse table>occurs 0,
wa like line type of itab.
in above two cases , in my view no difference.
in first case there will be one workarea will be created with same name itab,
in second case we are explicitly creating work area.
ok.
here my doubt is in what cases it is madatory to create internal table with explicitly work area?
thank in advance.
venuHi,
It is a good practice to define a structure for your internal table. Then declare an internal table with the defined structure. Using a workarea to access to the internal table.
TYPES : BEGIN OF struc_tab,
rec1(10) TYPE c,
END OF struc_tab.
DATA : itab TYPE TABLE OF struc_tab,
wa_itab LIKE LINE OF itab.
There is no differences, just that we're avoiding declaring using 'With Occurs 0' or 'With Header Line' and in some cases in oo programming, headerline are not allowed.
Regards,
Loo -
Problem while comparing two internal tables
I have to modify work start date which are initial in the data base table for the records in the flat file.
my code is:
REPORT ZAUFK_WORKSTARTDATE_UPDATE .
Tables Declaration
TABLES: AUFK.
Type pools Declaration
TYPE-POOLS : SLIS.
Internal Table Declaration
DATA: I_AUFK LIKE AUFK OCCURS 0 WITH HEADER LINE,
IT_AUFK LIKE AUFK OCCURS 0 WITH HEADER LINE,
ITAB1 LIKE ALSMEX_TABLINE OCCURS 0 WITH HEADER LINE.
DATA: BEGIN OF I_AUFK1 OCCURS 0,
AUFNR(12),
AUART(4),
END OF I_AUFK1.
Data Declaration
DATA I_FIELDCAT TYPE SLIS_FIELDCAT_ALV OCCURS 0.
DATA WA_FCAT LIKE LINE OF I_FIELDCAT.
DATA: B1 TYPE I VALUE 1,
C1 TYPE I VALUE 1,
B2 TYPE I VALUE 256,
C2 TYPE I VALUE 65536.
Selection Screen Declaration
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
PARAMETERS: P_FILE LIKE RLGRAP-FILENAME.
SELECT-OPTIONS: S_AUFNR FOR AUFK-AUFNR,
S_AUART FOR AUFK-AUART.
PARAMETERS: P_USER7 LIKE AUFK-USER7 DEFAULT '20070101' OBLIGATORY.
SELECTION-SCREEN END OF BLOCK B1.
SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-002.
PARAMETERS: R1 RADIOBUTTON GROUP G1 DEFAULT 'X' USER-COMMAND UCOMM1, " Upload using File Path
R2 RADIOBUTTON GROUP G1. " Uplaod using particular IO's
SELECTION-SCREEN END OF BLOCK B2.
To get F4 Help for File path on selection screen.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
IMPORTING
FILE_NAME = P_FILE.
To disbale the filepath when r2 radiobutton is selected
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
Check if R1 is checked
IF R1 = 'X'.
IF SCREEN-NAME = 'S_AUFNR-LOW' OR
SCREEN-NAME = 'S_AUFNR-HIGH' OR
SCREEN-NAME = 'S_AUART-LOW' OR
SCREEN-NAME = 'S_AUART-HIGH'.
Make the Internal order number and order type field disable from the selection screen
SCREEN-INPUT = '0'.
MODIFY SCREEN.
ENDIF.
ELSEIF R2 = 'X' AND SCREEN-NAME = 'P_FILE'.
Make the file path field disappear from the selection screen
SCREEN-INPUT = 0.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
Start of executable code
START-OF-SELECTION.
To get the relavent IO data from the order master data table
SELECT *
FROM AUFK
INTO TABLE I_AUFK
WHERE AUFNR IN S_AUFNR
AND AUART IN S_AUART
AND ( AUART = '5200' OR AUART = '5500'
OR AUART = '5700' OR AUART = '8500'
OR AUART = '8700' ).
Table must be updated using flat file
IF R1 = 'X'.
To Upload Excel sheet data into an internal table
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = P_FILE
I_BEGIN_COL = B1
I_BEGIN_ROW = C1
I_END_COL = B2
I_END_ROW = C2
TABLES
INTERN = ITAB1
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
To organize the data in the internal table(excel data) as per our requirement
PERFORM ORGANIZE_UPLOADED_DATA.
<b> LOOP AT I_AUFK1.
Comparing the excel data and the database table data
READ TABLE I_AUFK WITH KEY AUFNR = I_AUFK1-AUFNR.
IF SY-SUBRC EQ 0.
Check if the the work start date is initial(blank)
IF I_AUFK-USER7 IS INITIAL.
If work start is initial move the value in p_user7 to the work start date field in i_aufk
MOVE P_USER7 TO I_AUFK-USER7.
MODIFY I_AUFK.
Moving the data which is changed into it_aufk internal table(this table is for displaying the updated records)
MOVE-CORRESPONDING I_AUFK TO IT_AUFK.
APPEND IT_AUFK.
ENDIF.
ENDIF.
ENDLOOP.
endif.</b>
WA_FCAT-FIELDNAME = 'AUFNR'.
WA_FCAT-TABNAME = 'I_AUFK'.
WA_FCAT-SELTEXT_M = 'Internal Order Number'.
WA_FCAT-OUTPUTLEN = 12.
APPEND WA_FCAT TO i_fieldcat.
WA_FCAT-FIELDNAME = 'AUART'.
WA_FCAT-TABNAME = 'I_AUFK'.
WA_FCAT-SELTEXT_M = 'Order Type'.
WA_FCAT-OUTPUTLEN = 4.
APPEND WA_FCAT TO I_FIELDCAT.
WA_FCAT-FIELDNAME = 'KTEXT'.
WA_FCAT-TABNAME = 'I_AUFK'.
WA_FCAT-SELTEXT_M = 'Description'.
WA_FCAT-OUTPUTLEN = 40.
APPEND WA_FCAT TO I_FIELDCAT.
WA_FCAT-FIELDNAME = 'USER7'.
WA_FCAT-TABNAME = 'I_AUFK'.
WA_FCAT-SELTEXT_M = 'Work Start Date'.
WA_FCAT-OUTPUTLEN = 10.
APPEND WA_FCAT TO I_FIELDCAT.
Updating the AUFK(Internal Order Data Table) using i_aufk
*MODIFY AUFK FROM TABLE I_AUFK.
Check if the database table is modified
*IF SY-SUBRC = 0.
Display the modified data
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
I_GRID_TITLE = 'List of updated Records'
IT_FIELDCAT = I_FIELDCAT[]
TABLES
T_OUTTAB = IT_AUFK[]
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.
ENDIF.
*& Form ORGANIZE_UPLOADED_DATA
text
FORM ORGANIZE_UPLOADED_DATA .
SORT ITAB1 BY ROW COL.
LOOP AT ITAB1.
CASE ITAB1-COL.
WHEN 1.
I_AUFK1-AUFNR = ITAB1-VALUE.
WHEN 2.
I_AUFK1-AUART = ITAB1-VALUE.
ENDCASE.
AT END OF ROW.
APPEND I_AUFK1.
ENDAT.
ENDLOOP.
LOOP AT I_AUFK1.
CONCATENATE '000000' I_AUFK1-AUFNR INTO I_AUFK1-AUFNR.
MODIFY I_AUFK1.
ENDLOOP.
ENDFORM. " ORGANIZE_UPLOADED_DATA
The bold are is were i'm facing problem. Please help me .its urgent.Hi try using the below code...
LOOP AT I_AUFK1.
Comparing the excel data and the database table data
READ TABLE I_AUFK WITH KEY AUFNR = I_AUFK1-AUFNR.
IF SY-SUBRC EQ 0.
Check if the the work start date is initial(blank)
IF I_AUFK-USER7 IS INITIAL.
If work start is initial move the value in p_user7 to the work start date field in i_aufk
MOVE P_USER7 TO I_AUFK-USER7.
[<u>b]MODIFY I_AUFK from i_aufk transporting user7.</b></u>
Moving the data which is changed into it_aufk internal table(this table is for displaying the updated records)
MOVE-CORRESPONDING I_AUFK TO IT_AUFK.
APPEND IT_AUFK.
ENDIF.
ENDIF.
ENDLOOP.
endif.
if you can't still solve some more questions
what is teh sy-subrc of teh read ..
what does the header line contain after teh read
and what happens after modify.. does the contents change? -
How to compare two entries in the same internal table
Hi
I hav e an internal table. I want to compare the entries in the internal table and delete the entries which is duplicates from the internal table. for ex. if plant 1000 is repeated two times. Then both the record of plant 1000 should be removed .
Please suggest some idea.
Thanks
SubhaHi,
Apply this code.
include one more field in itab & jtab as delete_flag(1) type c.
move itab to jtab.
Loop at itab into wa_itab.
lv_tabix = sy-tabix.
Loop at jtab into wa_jtab where plant = wa_itab-plant.
if sy-tabix ne lv_tabix.
wa_itab-delete_flag = 'X'.
endif.
Endloop.
modify itab from wa_itab transporting delete_flag.
clear: wa_itab,wa_jtab.
endloop.
delete itab where delete_flag = 'X'.
Now you have filtered ITAB with your desired results.
It will surely help.
Edited by: Adarsh Jain on Aug 18, 2010 7:57 AM
Edited by: Adarsh Jain on Aug 18, 2010 7:58 AM -
Comparing Application server file and internal table
hi all
Iam new to the world of ABAP. I have a requirement wherein i need to compare data in a internal table and that of the file. I need to extract the delta records( ie the record is found in the internal table but not in the file and vice versa ) and put it in another internal table. Which is the best way to do it?
Awaiting quick reply. Thanks
Nirmal.Hello Nimal
First read the file into your itab. For comparison you can use the same logic as change documents are prepared. Assuming both of your itabs are of structure struc_a. Then define the following type:
TYPES: BEGIN OF ty_s_itab_di.
INCLUDE TYPE struc_a.
TYPES: CHIND TYPE bu_chind.
TYPES: END OF ty_s_itab_di.
TYPES: ty_t_itab_di TYPE STANDARD TABLE OF ty_s_itab_di
WITH DEFAULT KEY.
DATA:
gt_itab_old TYPE ty_t_itab_di,
gt_itab_new TYPE ty_t_itab_di.
Fill itabs gt_Itab_old with the corresponding data of itab1 and gt_itab_new with the corresponding data of itab2.
Very important: sort you itabs either by all key fields or by all fields.
Call function CHANGEDOCUMENT_PREPARE_TABLES with the following parameters:
- CHECK_INDICATOR = ' '
- TABLE_NEW = gt_Itab_new
- TABLE_OLD = gt_itab_old
The function module will remove identical lines from both itabs. New entries in gt_itab_New will have CHIND = 'I' and deleted entries in gt_itab_old will have CHIND = 'D'.
Read the documentation of the function module and play around with it. You will see that this a quite easy yet powerful approach for comparing itabs.
Regards
Uwe -
Hi,
I'm getting stext & role_text from my internal table(which is populated from an excel sheet) and I have to compare them if they are similar or not.....how to do it....
Regards,
sunnyI'm getting stext & role_text from my internal table(which is populated from an excel sheet) and I have to compare them if they are similar or not.....how to do it....
Hi,
You can do as below:
loop at itab.
if itab-stext eq itab-role_text.
"Necessary process
else.
"Necessary process
endif.
endloop.
Thanks,
Sriram Ponna. -
How to read an internal table by comparing the values of key fields
hi ,
i want to read internal table with multiple values for the key field . can anyone suggest the syntax or method for doing this,
thanks in advance.
regards,
manojHi,
Read statement will read only one value at a time..
You can only compare with different values.
example :
read table it_mara into wa_mara with key matnr = '1000'
matnr = '2000'
matnr = '3000'.
if all the 3 records are found in the internal table then it will read the 1 record.
Regards
Satish Boguda -
Function module for comparing contents of two internal tables
Hi All,
Is there any function module to compare contents of two internal tables of same structure?
If yes please let me know.
Thanks in advance.
AmolHi
call SE16 with table TFTIT in order to get a full list (it will be long...)
A list of FMs with parameters can be found in table FUNCT.
Finally go to sm37rsdf4
that will give you all the function modules with description
Here is the list:
http://www.erpgenie.com/abap/functions.htm
hope this helps...
Regards
CSM Reddy
Maybe you are looking for
-
How can i get money back for a iphone app, how can i get money back for a iphone app
I go a 59p polaroid app, and the second day i tryed to use it, it would not start up. is there a way i can get my money back?
-
How to populate the Quering data into Excel sheet in Oracle
Dear Guys, How to populate the Quering data into Excel sheet in oracle. Please provide a solution. Thanks & Regards, Senthil K Kumar
-
Apache Commons Net - Retrieve File - Extension, Compare , Move - FTP Server
Dear All, I am using Apache Commons net FTP Library for FTP Operations. I had a few doubts 1) I like to retrieve ftp files only with some extensions like *.txt or *.jpg etc. How can we retrieve files with specifying file extension? 2) I need to compa
-
Hi, We have a staging environment which is a farm and We want to create a new production farm for share point 2010.(This farm is for Internet sites(public sites). not for Intranet as of now) Can I know how do I know how many servers do we need (i mea
-
On the new ViewSonic gTablet 10.1 inch screen - rebuilt to use a base Android 2.2 OS and not the faulty one from Viewsonic, I loaded the Firefox 4 beta for Mobile. The issue is that it is not giving me an option to allow it to show all content in a n