Processing in 2 internal tables -Performance wise better option
Hi Experts,
I have 2 internal tables.
ITAB1 and ITAB2 both are sorted by PSPHI.
ITAB1 has PSPHI some more fields INVOICE DATE and AMT
ITAB2 has PSPHI some more fields amount.
Both itab1 and itab2 will always have same amount of data.
I need to filter data from ITAB2 based invoice date given on selection screen.since ITAB2 doesnt have invoice date field.
i am doing further processing to filter the records.
I have thought of below processing logic and wanted to know if there is a better option performance wise?
loop at ITAB1 into wa where invoice_date > selection screen date. (table which has invoice date)
lv_index = sy-tabix.
read table itab2 where psphi = wa-psphi and index = lv_index.
if sy-subrc = 0.
delete itab2 index lv_index.
endif.
endloop.
Hi Madhu,
My Requirement is as below could you please advice on this ?
ITAB1
Field 1 PSPHI , FIELD 2 INVOICE, FIELD 3 INVOICE_DATE , FIELD4 AMT
15245, INV1, 02/2011 , 400
15245 INV2 02/2012 , 430
ITAB2
Field 1 PSPHI , FIELD 2 PSNR, FIELD 3 MATNR , FIELD4 AMT
15245, PSNR1, X . 430
15245 IPSNR2 Y, 400
When user enteres date on sel screen as 02/2011
I want to delete the data from itab1 and itab2 for invoice date greater then 02/2011/
If i delere ITAB1 for date > selection screen date.
Loop itab1.
delete itab2 where psphi in itab1 will delete both rows in above example because the field psphi which is common can be mutiple.
endloop.
Can you advice ?
Similar Messages
-
Which is Performance wise better MOVE or MOVE CORRESPONDING ...
Hi SAP-ABAP Experts .
Which is Performance wise better ...
MOVE or MOVE CORRESPONDING .
Regards : Rajneesh> A
>
> * access path and indexes
Indexes and hence access paths are defined when you design the data model. They are part of the model design.
> * too large numbers of records or executions
consider a datawarehouse environment - you have to deal with huge loads of data. a Million records are considered "small" here. Terms like "small" or "large" are depending on the context you are working in.
If you never heard of Star transformation, Partitioning and Parallel Query you will get lost here!
OLTP is different: you have short transactions, but a huge number of concurrent users.
You would not even consider Bitmap indexes in an OLTP environment - but maybe a design that evenly distributes data blocks over several files for avoiding hot spots on heavily used tables.
> * processing of internal tables => no quadratic coding
>
> these are the main performance issues!
>
> > Performance is defined at design time
> partly yes, but more is determined during runtime, you must check everything at least once. Many things can go wrong and will go wrong.
sorry, it's all about the data model design - sure you have to tune later in the development but you really can't tune successfully on a BAD data model ... you have to redesign.
If the model is good there is a chance the developers chooses the worst access to it , but then you have the potential to tune with success because your model allows for a better access strategy.
The decisions you make in the design phase are detemining the potential for tuning later.
>
> * database does not what you expect
I call this the black box view: The developer is not interested in the underlying database.
Why we have different DB vendors if they would all behave the same way? I.e. compare concurrency
and consistency implementations in various DB's - totally different. You can't simply apply your working knowledge from one database to another DB product. I learned the hard way while implementing on INFORMIX and ORACLE... -
Making processing on an internal table generic
Hi,
I'm trying to make more generic a processing on an internal table.
Here's the idea :
"DELETE FROM TABLE T_VBAP every lines that do not exist IN table T_VBAK USING column VBELN for comparison"
You can see below the (not generic) version of this function.
I'd like to make it more generic.
It would be called this way :
PERFORM reduire USING t_vbak t_vbap 'VBELN' 'vbak-vbeln'.
with the following code.
Here is my question :
How can I make the last statement generic too ?
DELETE <table_travail> WHERE (column) NOT IN <fs_tab> won't work...
Thanks a lot !
Jessie
Non-generic version :
FORM reduire.
DATA : liste_vbeln type range of vbak-vbeln,
line_vbeln TYPE LINE OF liste_vbeln,
lt_vbak TYPE TABLE OF ts_vbak,
lt_vbap TYPE ts_vbak.
lt_vbak = t_vbak.
SORT lt_vbak BY vbeln.
DELETE ADJACENT DUPLICATES FROM lt_vbak COMPARGIN vbeln.
line_vbeln-sign = 'I'.
line_vbeln-option = 'EQ'.
LOOP AT lt_vbak INTO ls_vbak.
line_vbeln-low = ls_vbak-vbeln.
APPEND line_vbeln TO liste_vbeln.
ENDLOOP.
IF liste_vbeln IS INITIAL.
CLEAR t_vbap.
ELSE.
DELETE t_vbap WHERE vbeln NOT IN liste_vbeln.
ENDIF.
ENDFORM.
Generic version :
FORM reduire USING p_reference STANDARD TABLE
p_travail TYPE STANDARD TABLE
column TYPE lvc_name
column_type TYPE string.
FIELD-SYMBOLS <table_reference> TYPE STANDARD TABLE.
FIELD-SYMBOLS <table_reference_copy> TYPE STANDARD TABLE.
ASSIGN p_reference to <table_reference>.
FIELD-SYMBOLS <table_travail> TYPE STANDARD TABLE.
ASSIGN p_travail to <table_travail>.
FIELD-SYMBOLS <table_reference_fields> TYPE ANY.
DATA gs_fldname TYPE REF TO DATA.
CREATE DATA gs_fldname LIKE LINE OF <table_reference>.
ASSIGN gs_fldname->* TO <table_reference_fields>.
DATA position TYPE i.
DATA dyn_table TYPE REF TO DATA.
DATA wa_fieldcat TYPE lvc_s_fcat.
DATA it_fieldcat TYPE lvc_t_fcat.
DATA table_reference_copy_pre TYPE REF TO DATA.
DATA l_descr_ref TYPE REF TO cl_abap_structdescr.
FIELD-SYMBOLS <ls_tab> TYPE ANY.
FIELD-SYMBOLS <field> TYPE ANY.
FIELD-SYMBOLS <lfs_comp_wa> TYPE abap_compdescr.
l_descr_ref ?= cl_abap_typedescr=>describe_by_data( <table_reference_fields> ).
LOOP AT l_descr_ref->components[] ASSIGNING <lfs_comp_wa>.
IF <lfs_comp_wa>-name = column.
position = sy-tabix.
ENDIF.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = <lfs_comp_wa>-name.
wa_fieldcat-datatype = <lfs_comp_wa>-type_kind.
wa_fieldcat-inttype = <lfs_comp_wa>-type_kind.
wa_fieldcat-intlen = <lfs_comp_wa>-length / 2.
wa_fieldcat-decimals = <lfs_comp_wa>-decimals.
APPEND wa_fieldcat TO it_fieldcat.
ENDLOOP.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = it_fieldcat
IMPORTING
ep_table = table_reference_copy_pre.
ASSIGN table_reference_copy_pre->* TO <table_reference_copy>.
<table_reference_copy> = p_reference.
SORT <table_reference_copy> BY (column).
DELETE ADJACENT DUPLICATES FROM <table_reference> COMPARING (column).
DATA :
gr_structdescr TYPE REF TO cl_abap_structdescr,
gr_tabledescr TYPE REF TO cl_abap_tabledescr,
gr_datadescr TYPE REF TO cl_abap_datadescr,
gr_typedescr TYPE REF TO cl_abap_typedescr,
gt_components TYPE abap_component_tab,
gw_component TYPE LINE OF abap_component_tab,
gr_wa TYPE REF TO DATA,
gr_tab TYPE REF TO DATA.
FIELD-SYMBOLS :
<fs_wa> TYPE ANY,
<fs_tab> TYPE TABLE.
MOVE 'SIGN' to gw_component-name.
gw_component-type ?= cl_abap_elemdescr=>get_c( p_length = 1 ).
INSERT gw_component INTO TABLE gt_components.
MOVE 'OPTION' to gw_component-name.
gw_component-type ?= cl_abap_elemdescr=>get_c( p_length = 2 ).
INSERT gw_component INTO TABLE gt_components.
MOVE 'LOW' to gw_component-name.
gw_component-type ?= cl_abap_elemdescr=>describe_by_name( column_type ).
INSERT gw_component INTO TABLE gt_components.
MOVE 'HIGH' to gw_component-name.
gw_component-type ?= cl_abap_elemdescr=>describe_by_name( column_type ).
INSERT gw_component INTO TABLE gt_components.
gr_structdescr ?= cl_abap_structdescr=>create( gt_components ).
CREATE DATA gr_wa TYPE HANDLE gr_structdescr.
ASSIGN gr_wa->* to <fs_wa>.
gr_datadescr ?= gr_structdescr.
gr_tabledescr ?= cl_abap_tabledescr=>create( gr_datadescr ).
CREATE DATA gr_tab TYPE HANDLE gr_datadescr.
ASSIGN gr_tab->* TO <fs_tab>.
LOOP AT <table_reference> ASSIGNING <ls_tab>.
ASSIGN COMPONENT position OF STRUCTURE <ls_tab> to <field>.
CONCATENATE 'IEQ' <field> INTO <fs_wa>.
APPEND <fs_wa> TO <fs_tab>.
ENDLOOP.
DELETE t_vbap WHERE vbeln NOT IN <fs_tab>.
ENDFORM.Hello Jessie,
Which ABAP Release are you working on? Dynamic WHERE conditions for LOOP AT itab, MODIFY itab, and DELETE itab statements are possible from Release 702.
Even if you're on 702, the statement DELETE <table_travail> WHERE (column) NOT IN <fs_tab> won't work! You need to change your coding to:
DATA lv_dyn_cond TYPE string.
CONCATENATE column `NOT IN` `<FS_TAB>` INTO lv_dyn_cond SEPARATED BY space.
DELETE <table_travail> WHERE (lv_dyn_cond).
BR,
Suhas -
How to do parallel processing with dynamic internal table
Hi All,
I need to implement parallel processing that involves dynamically created internal tables. I tried doing so using RFC function modules (using starting new task and other such methods) but didn't get success this requires RFC enabled function modules and at the same time RFC enabled function modules do not allow generic data type (STANDARD TABLE) which is needed for passing dynamic internal tables. My exact requirement is as follows:
1. I've large chunk of data in two internal tables, one of them is formed dynamically and hence it's structure is not known at the time of coding.
2. This data has to be processed together to generate another internal table, whose structure is pre-defined. But this data processing is taking very long time as the number of records are close to a million.
3. I need to divide the dynamic internal table into (say) 1000 records each and pass to a function module and submit it to run in another task. Many such tasks will be executed in parallel.
4. The function module running in parallel can insert the processed data into a database table and the main program can access it from there.
Unfortunately, due to the limitation of not allowing generic data types in RFC, I'm unable to do this. Does anyone has any idea how to implement parallel processing using dynamic internal tables in these type of conditions.
Any help will be highly appreciated.
Thanks and regards,
Ashintry the below code...
DATA: w_subrc TYPE sy-subrc.
DATA: w_infty(5) TYPE c.
data: w_string type string.
FIELD-SYMBOLS: <f1> TYPE table.
FIELD-SYMBOLS: <f1_wa> TYPE ANY.
DATA: ref_tab TYPE REF TO data.
CONCATENATE 'P' infty INTO w_infty.
CREATE DATA ref_tab TYPE STANDARD TABLE OF (w_infty).
ASSIGN ref_tab->* TO <f1>.
* Create dynamic work area
CREATE DATA ref_tab TYPE (w_infty).
ASSIGN ref_tab->* TO <f1_wa>.
IF begda IS INITIAL.
begda = '18000101'.
ENDIF.
IF endda IS INITIAL.
endda = '99991231'.
ENDIF.
CALL FUNCTION 'HR_READ_INFOTYPE'
EXPORTING
pernr = pernr
infty = infty
begda = '18000101'
endda = '99991231'
IMPORTING
subrc = w_subrc
TABLES
infty_tab = <f1>
EXCEPTIONS
infty_not_found = 1
OTHERS = 2.
IF sy-subrc <> 0.
subrc = w_subrc.
ELSE.
ENDIF. -
Internal table values to select-options
Hi,
I have to modify an existing program.
here
1. I am populating one field in the selection-screen with a file path which contain some data.
2. then this file i am converting into an internal table.(At selection-screen event)
<b>Now, i have to pass this data of the internal table to a select-option in the selection-screen back.</b>
how it is possible, i have tried a lot.
please help me.
Regards,
Maahi.tables bkpf.
data: begin of itab occurs 0.
INCLUDE STRUCTURE alsmex_tabline.
data end of itab.
PARAMETERS p_fpath like rlgrap-filename.
SELECT-OPTIONS rbelnr FOR bkpf-belnr.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_fpath.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
* PROGRAM_NAME = SYST-REPID
* DYNPRO_NUMBER = SYST-DYNNR
* FIELD_NAME = ' '
STATIC = 'X'
* MASK = ' '
CHANGING
FILE_NAME = p_fpath
* EXCEPTIONS
* MASK_TOO_LONG = 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.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = p_fpath
I_BEGIN_COL = 1
I_BEGIN_ROW = 1
I_END_COL = 1
I_END_ROW = 2000
TABLES
INTERN = itab
* 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.
sort itab by value.
delete adjacent duplicates from itab comparing value.
now after this i have to implement the logic in 3rd point.
thanks ,
Maahi -
Loop Internal Table Performance
Hi I am from BW and not much familiar with ABAP. I have written the following code in BW. I have around 1.5 million records coming into BW and the code I have written needs to go through 1.5 million times. Hence the data load is taking long time. I would like someone to please go through the code below and suggest if any for performance improvement.
data: i_datapackage like DATA_PACKAGE occurs 0 with header line,
i_index like sy-tabix,
j_index like sy-tabix,
i_employee like /bi0/memployee occurs 0 with header line,
i_begda like /bi0/memployee occurs 0 with header line.
prev_job like i_employee-job,
prev_position like i_employee-hrposition,
curr_job like i_employee-job,
curr_position like i_employee-hrposition,
job_datefrom like i_employee-datefrom,
position_datefrom like i_employee-datefrom,
prejob_datefrom like i_employee-datefrom,
prepos_datefrom like i_employee-datefrom,
prejob_dateto like i_employee-datefrom,
prepos_dateto like i_employee-datefrom.
i_datapackage[] = DATA_PACKAGE[].
sort i_datapackage by employee calmonth ascending.
select * from /bi0/memployee into table i_employee.
sort i_employee by employee dateto descending.
i_begda[] = i_employee[].
sort i_begda by employee datefrom ascending.
delete adjacent duplicates from i_employee comparing employee.
loop at i_datapackage.
*collecting current job,position, previous job, position
read table i_employee with key employee = i_datapackage-employee
dateto ='99991231'.
if sy-subrc = 0.
curr_job = i_employee-job.
curr_position = i_employee-hrposition.
endif.
read table i_begda with key employee = i_datapackage-employee.
if sy-subrc = 0.
prev_job = i_begda-/bic/zhr_pjob.
prev_position = i_begda-/bic/zhr_ppost.
endif.
*end of collecting current job and position
sort i_begda by employee datefrom descending.
read table i_begda with key employee = i_datapackage-employee
binary search.
if sy-subrc = 0.
i_index = sy-tabix.
endif.
read table i_begda index i_index.
if i_begda-employee ne i_datapackage-employee.
exit.
endif.
code for populating service award tenure
if i_begda-/bic/zhr_srvdt is not initial.
i_datapackage-/bic/zhr_hrtnr = sy-datum+0(4) -
i_begda-/BIC/ZHR_SRVDt+0(4).
if sy-datum4(4) lt i_begda-/bic/zhr_srvdt4(4).
i_datapackage-/bic/zhr_hrtnr = i_datapackage-/bic/zhr_hrtnr - 1.
endif.
endif.
code for current hire tenure
if i_begda-/bic/zhr_curdt is not initial.
i_datapackage-/bic/zhr_crtnr = sy-datum+0(4) -
i_begda-/BIC/ZHR_CURDT+0(4).
if sy-datum4(4) lt i_begda-/BIC/ZHR_CURDT4(4).
i_datapackage-/BIC/ZHR_CRTNR = i_datapackage-/bic/zhr_crtnr - 1.
endif.
endif.
code for current supervisor tenure
if i_begda-/bic/zhr_csbdt is not initial.
i_datapackage-/bic/ZHR_CSTNR = sy-datum+0(4) -
i_begda-/BIC/ZHR_CSBDT+0(4).
if sy-datum4(4) lt i_begda-/BIC/ZHR_CSBDT4(4).
i_datapackage-/bic/ZHR_CSTNR = i_datapackage-/bic/ZHR_CSTNR - 1.
endif.
endif.
code for previous supervisor tenure
if i_begda-/bic/zhr_psbdt is not initial.
i_datapackage-/bic/ZHR_PSTNR = sy-datum+0(4) -
i_begda-/BIC/ZHR_PSBDT+0(4).
if sy-datum4(4) lt i_begda-/BIC/ZHR_PSBDT4(4).
i_datapackage-/bic/ZHR_PSTNR = i_datapackage-/bic/ZHR_PSTNR - 1.
endif.
endif.
Code for populating Years in current job
and current position
sort i_begda by employee datefrom ascending.
clear j_index.
read table i_begda with key employee = i_datapackage-employee.
if sy-subrc = 0.
j_index = sy-tabix.
endif.
loop at i_begda from j_index.
if i_begda-employee ne i_datapackage-employee.
exit.
elseif ( i_begda-job eq curr_job ) and
( curr_job is not initial ).
job_datefrom = i_begda-datefrom.
prejob_dateto = i_begda-datefrom - 1.
exit.
endif.
endloop.
loop at i_begda from j_index.
if i_begda-employee ne i_datapackage-employee.
exit.
elseif ( i_begda-hrposition eq curr_position ) and
( curr_position is not initial ).
position_datefrom = i_begda-datefrom.
prepos_dateto = i_begda-datefrom - 1.
exit.
endif.
endloop.
loop at i_begda from j_index.
if i_begda-employee ne i_datapackage-employee.
exit.
elseif ( i_begda-job eq prev_job ) and
( prev_job is not initial ) and
( i_begda-datefrom ne '10000101').
prejob_datefrom = i_begda-datefrom.
exit.
endif.
endloop.
loop at i_begda from j_index.
if i_begda-employee ne i_datapackage-employee.
exit.
elseif ( i_begda-hrposition eq prev_position ) and
( prev_position is not initial ) and
( i_begda-datefrom ne '10000101').
prepos_datefrom = i_begda-datefrom.
exit.
endif.
endloop.
i_datapackage-/bic/zhr_cjtnr = sy-datum+0(4) -
job_datefrom+0(4).
if sy-datum4(4) lt job_datefrom4(4).
i_datapackage-/bic/zhr_cjtnr = i_datapackage-/bic/zhr_cjtnr - 1.
endif.
if position_datefrom+0(4) is not initial.
i_datapackage-/bic/zhr_cptnr = sy-datum+0(4) -
position_datefrom+0(4).
if sy-datum4(4) lt position_datefrom4(4).
i_datapackage-/bic/zhr_cptnr = i_datapackage-/bic/zhr_cptnr - 1.
endif.
endif.
if prejob_datefrom is not initial.
i_datapackage-/bic/zhr_pjtnr = prejob_dateto+0(4) -
prejob_datefrom+0(4).
if prejob_dateto4(4) lt prejob_datefrom4(4).
i_datapackage-/bic/zhr_pjtnr = i_datapackage-/bic/zhr_pjtnr - 1.
endif.
endif.
if prepos_datefrom is not initial.
i_datapackage-/bic/zhr_pptnr = prepos_dateto+0(4) -
prepos_datefrom+0(4).
if prepos_dateto4(4) lt prepos_datefrom4(4).
i_datapackage-/bic/zhr_pptnr = i_datapackage-/bic/zhr_pptnr - 1.
endif.
endif.
modify i_datapackage transporting /bic/zhr_hrtnr /bic/zhr_crtnr
/bic/zhr_cstnr /bic/ZHR_PSTNR /bic/zhr_cjtnr /bic/zhr_cptnr
/bic/zhr_pjtnr /bic/zhr_pptnr.
endloop.
DATA_PACKAGE[] = i_datapackage[].
Thanks.i_datapackage[] = DATA_PACKAGE[].
i_begda[] = i_employee[].
How larger are these internal tables ?
If large, then
> sort i_begda by employee datefrom descending.
> read table i_begda with key employee = i_datapackage-employee binary search.
the resorting and
the nested loops
=> will kill your performance
Please reconsider the whole logic, I have only some hints
+ Binary search does not help anything if you have to sort everytime you use it.
+ Never use a sort of a larger table inside a larger loop, it is always avoidable!
+ Check whether you can break down the big piece into smaller one, try to
do the break down in the database already to save memory
=> Please provide your code in better layout, and explain what you actually want
to do.
Siegfried -
How to process very large internal tables and stop time limit
Hello Experts,
I am currently having a problem on how to fix a certain report where we process more than 500 thousand
records in the internal table. I can't think of any solution that can make the below code any faster.
I just checked in our prod server and the error time limit exceeded stops in the loop statement. Anyway,
Below is the code. Any input will be appreciated. Thanks guys and take care!
Get sales document and corresponding line item
SELECT avbeln bposnr a~auart
avkorg avtweg a~kunnr
bmatnr bpstyv b~spart
FROM vbak AS a
INNER JOIN vbap AS b
ON avbeln = bvbeln
APPENDING TABLE lt_vbap
WHERE a~auart IN lr_auart
AND a~vbeln IN s_vbeln
AND a~vbeln IN s_vbill
AND a~vbtyp EQ p_vbtyp.
LOOP AT lt_vbap ASSIGNING <wa_vbap>.
IF <wa_vbap>-auart EQ 'ZUCI' OR
<wa_vbap>-auart EQ 'ZURV' OR
<wa_vbap>-auart EQ 'ZUPR'.
Check ifa delivery document has been created
CLEAR wa_vbill.
SELECT SINGLE vbeln
FROM vbfa
INTO wa_vbill
WHERE vbelv = <wa_vbap>-vbeln
AND ( ( vbtyp_n EQ 'J' AND vbtyp_v = 'C' )
OR ( vbtyp_n EQ 'T' AND vbtyp_v = 'H' ) ).
IF sy-subrc <> 0.
<wa_vbap>-del_ind = 'X'.
CONTINUE.
ELSE.
Check if within selection parameters
CLEAR wa_likp.
READ TABLE lt_likp INTO wa_likp WITH KEY vbeln = wa_vbill.
IF sy-subrc <> 0.
SELECT SINGLE *
FROM likp
INTO wa_likp
WHERE vbeln = wa_vbill.
APPEND wa_likp TO lt_likp.
ENDIF.
IF NOT wa_likp-wadat_ist IN s_erdat.
<wa_vbap>-del_ind = 'X'.
CONTINUE.
ENDIF.
ENDIF.
ELSE.
Check if this has already been billed
CLEAR wa_vbill.
SELECT SINGLE vbeln
FROM vbfa
INTO wa_vbill
WHERE vbelv = <wa_vbap>-vbeln
AND ( ( vbtyp_n EQ 'M' AND vbtyp_v = 'C' )
OR ( vbtyp_n EQ 'O' AND vbtyp_v = 'H' ) ).
IF sy-subrc <> 0.
<wa_vbap>-del_ind = 'X'.
CONTINUE.
ELSE.
Check if within selection parameters
CLEAR wa_vbrk.
READ TABLE lt_vbrk INTO wa_vbrk WITH KEY vbeln = wa_vbill.
IF sy-subrc <> 0.
SELECT SINGLE vbeln fkdat
FROM vbrk
INTO wa_vbrk
WHERE vbeln = wa_vbill.
APPEND wa_vbrk TO lt_vbrk.
ENDIF.
IF NOT wa_vbrk-fkdat IN s_erdat.
<wa_vbap>-del_ind = 'X'.
CONTINUE.
ENDIF.
ENDIF.
ENDIF.
Get Material Type and Division
IF <wa_vbap>-spart IS NOT INITIAL.
SELECT SINGLE mtart
FROM mara
INTO lv_mtart
WHERE matnr = <wa_vbap>-matnr.
ELSE.
SELECT SINGLE mtart spart
FROM mara
INTO (lv_mtart,<wa_vbap>-spart)
WHERE matnr = <wa_vbap>-matnr.
ENDIF.
If material division is same as parameter division
IF <wa_vbap>-spart = p_spart.
If material is subsidiary-owned
IF <wa_vbap>-spart in lr_spart.
If customer is the same as that of parameter division
IF <wa_vbap>-kunnr NE lr_kunnr OR <wa_vbap>-auart EQ 'ZUDO' OR <wa_vbap>-auart EQ 'ZUS3'.
If item is a free good, tag order type as 'ZUPR' to treat
the item the same way as 'ZUPR'
IF <wa_vbap>-pstyv = 'TANN' OR
<wa_vbap>-pstyv = 'ZKNF' OR
<wa_vbap>-pstyv = 'ZKNN' OR
<wa_vbap>-pstyv = 'ZFLO' OR
<wa_vbap>-pstyv = 'ZKBF' OR
<wa_vbap>-pstyv = 'ZKLN' OR
<wa_vbap>-pstyv = 'ZREN'.
lv_auart = <wa_vbap>-auart.
IF lv_auart EQ 'ZUPR'.
CLEAR <wa_vbap>-pstyv.
ENDIF.
<wa_vbap>-auart = 'ZUPR'.
CLEAR: lv_mtart.
ENDIF.
Set Cost of Goods Sold Account
<wa_vbap>-cogshkont = '0050000010'.
CASE <wa_vbap>-auart.
WHEN 'ZUPR'.
CASE lv_mtart.
WHEN 'ZUL4'.
<wa_vbap>-del_ind = 'X'.
CONTINUE.
WHEN OTHERS.
Check if division is defined in mapping table
READ TABLE lt_ulsub INTO wa_ulsub
WITH KEY spart = <wa_vbap>-spart.
IF sy-subrc = 0.
<wa_vbap>-kostl = wa_ulsub-kostlp.
<wa_vbap>-bukrs = wa_ulsub-bukrsp.
<wa_vbap>-type = 'TP'.
Set Cost of Goods Sold Account
IF lv_auart = 'ZUPR'.
<wa_vbap>-cogshkont = '0050000006'.
ENDIF.
ELSE.
<wa_vbap>-del_ind = 'X'.
CONTINUE.
ENDIF.
ENDCASE.
WHEN 'ZUCI' OR 'ZUDO' OR 'ZURD' OR 'ZUS3'.
Get cost center from header text
PERFORM get_cost_center USING <wa_vbap>-vbeln
CHANGING <wa_vbap>-kostl.
* Change by LGTE 11-02-2006
Check if Medvale sales
IF <wa_vbap>-auart EQ 'ZUCI' AND <wa_vbap>-kostl IS INITIAL.
<wa_vbap>-del_ind = 'X'.
CONTINUE.
Check if UL Cost Center
ELSEIF <wa_vbap>-kostl NE gv_ul_kostl.
IF <wa_vbap>-kostl NE gv_ul_kostl.
* End change.
Get material division and check if subsidiary product
SELECT SINGLE spart FROM mara INTO <wa_vbap>-spart
WHERE matnr = <wa_vbap>-matnr.
READ TABLE lt_ulsub INTO wa_ulsub
WITH KEY spart = <wa_vbap>-spart.
IF sy-subrc = 0.
Get requestor's company code from cost center data
SELECT SINGLE bukrs
FROM csks
INTO <wa_vbap>-bukrs
WHERE kokrs = lc_kokrs
AND kostl = <wa_vbap>-kostl
AND datbi GE sy-datum
AND datab LE sy-datum.
IF sy-subrc = 0.
For donations, only include if a subsidiary company is donating
IF <wa_vbap>-auart EQ 'ZUDO' OR <wa_vbap>-auart EQ 'ZUS3'.
IF NOT <wa_vbap>-kunnr IN lr_kunnrnt.
<wa_vbap>-del_ind = 'X'.
CONTINUE.
ENDIF.
CHECK <wa_vbap>-kunnr IN lr_kunnrnt.
ENDIF.
For ZUCI, if the company code of the costcenter is UL, do not include
IF <wa_vbap>-bukrs EQ gc_ul_bukrs.
<wa_vbap>-del_ind = 'X'.
CONTINUE.
ENDIF.
IF <wa_vbap>-bukrs = wa_ulsub-bukrsp.
<wa_vbap>-type = 'RV'.
ELSE.
<wa_vbap>-type = 'RV'.
ENDIF.
ELSE.
Check if customer defined in table ZFI_DONATIONS
SELECT SINGLE kunnr FROM zfi_donations INTO <wa_vbap>-kostl
WHERE kunnr = <wa_vbap>-kostl.
IF sy-subrc <> 0.
lv_error = 'X'.
CONCATENATE 'Cost center/Customer' <wa_vbap>-kostl
'does not exist. Please check Sales Order'
<wa_vbap>-vbeln
INTO lt_disp-message SEPARATED BY space.
lt_disp-type = 'E'.
<wa_vbap>-del_ind = 'X'.
APPEND lt_disp.
CONTINUE.
ELSE.
<wa_vbap>-type = 'RV'.
ENDIF.
ENDIF.
ELSE.
<wa_vbap>-del_ind = 'X'.
CONTINUE.
ENDIF.
ELSE.
<wa_vbap>-del_ind = 'X'.
CONTINUE.
ENDIF.
WHEN OTHERS.
<wa_vbap>-del_ind = 'X'.
CONTINUE.
ENDCASE.
ELSE.
<wa_vbap>-del_ind = 'X'.
CONTINUE.
ENDIF.
ELSE.
<wa_vbap>-del_ind = 'X'.
CONTINUE.
ENDIF.
Get company code description
SELECT SINGLE butxt FROM t001 INTO <wa_vbap>-butxt
WHERE bukrs = <wa_vbap>-bukrs.
IF sy-subrc <> 0.
SELECT SINGLE name1 FROM kna1 INTO <wa_vbap>-butxt
WHERE kunnr = <wa_vbap>-kostl.
ENDIF.
Change by LGTE on 11-02-2006
Get Transaction Type
CASE <wa_vbap>-auart.
WHEN 'ZUPR'. "UL Promo/Samples
IF <wa_vbap>-pstyv = 'TANN' OR
<wa_vbap>-pstyv = 'ZKNF' OR
<wa_vbap>-pstyv = 'ZKNN' OR
<wa_vbap>-pstyv = 'ZFLO' OR
<wa_vbap>-pstyv = 'ZKBF' OR
<wa_vbap>-pstyv = 'ZKLN' OR
<wa_vbap>-pstyv = 'ZREN'.
<wa_vbap>-ltext = 'Free Goods'.
ELSE.
<wa_vbap>-ltext = 'Product Samples'.
ENDIF.
WHEN 'ZUDO'. "Donations - R/3
<wa_vbap>-ltext = 'Donations - R/3'.
WHEN 'ZUCI'. "Donations - ZUCI
<wa_vbap>-ltext = 'Donations - ZUCI'.
WHEN 'ZURD' OR 'ZUS3'. "UL Returns - Donation
<wa_vbap>-ltext = 'UL Returns - Donation'.
ENDCASE.
Get material description
SELECT SINGLE maktx
FROM makt
INTO <wa_vbap>-maktx
WHERE matnr = <wa_vbap>-matnr
AND spras = sy-langu.
Get division from material master
SELECT SINGLE spart FROM mara INTO <wa_vbap>-spart
WHERE matnr = <wa_vbap>-matnr.
Get division description
SELECT SINGLE vtext
FROM tspat
INTO <wa_vbap>-vtext
WHERE spras = sy-langu
AND spart = <wa_vbap>-spart.
Get Valuation Class
SELECT SINGLE bklas
FROM mbew
INTO lv_bklas
WHERE matnr = <wa_vbap>-matnr.
Determine G/L of FG Based on Valuation Class
READ TABLE lt_val_cls INTO wa_val_cls WITH TABLE KEY bklas = lv_bklas.
<wa_vbap>-fghkont = wa_val_cls-hkont.
Determine Cost Center of Cogs Account
READ TABLE lt_ulsub INTO wa_ulsub WITH TABLE KEY spart = <wa_vbap>-spart.
<wa_vbap>-cogskostl = wa_ulsub-kostlp.Hi!
First of all, don't use SELECT SINGLE inside of LOOP,
instead SELECT all relevated rows before LOOP in intertal tables (using FOR ALL ENTRIES) and then use
READ TABLE WITH KEY BINARY SEARCH.
it will match faster.
for example:
IF NOT lt_vbap[] IS INITIAL.
SELECT vbeln
FROM vbfa
INTO lt_vbill
FOR ALL ENTRIES IN lt_vbap
WHERE vbelv = lt_vbap-vbeln.
ENDIF.
SORT lt_vbap BY vbeln.
READ TABLE lt_vbill WITH KEY vbeln = <wa_vbap>-vbeln
BINARY SEARCH. -
Reg : internal table & Perform statement
hi all
i have 3 internal tables ,
* in first internal table i have mark-1 ,*
* in 2nd internal table i have mark-2 ,*
* using "PERFORM" i have to add mark 1 & mark 2*
* and i need to display the total in 3rd internal table.*
* how to do by using "PERFORM" .*
Kindly clarify.
with kind regards
velRaghupathy is right you just have to write:
porgram code......
perform sum_of_tables tables itab1
itab2
itab3.
program code....
definition of form:
form_sum_of_tables tables itab1
itab2
itab3.
definiton type of witab1, witab2, witab3.
loop itab1 into witab1.
loop itab2 into witab2.
witab3-total = witab1-mark1 plus witab2-mark2.
append witab3 to itab3.
endloop.
endloop.
endform.
It will return itab3 which is sum of itab1 and itab2. -
How to Fetch Data into internal table column wise?
The internal table contains huge set of data. Normally we fetch the data row wise using insert and select statements in work area.
But, the requirement is on fetching the data column wise for each field from the database.
So,can anyone help me on this issue for fetching the data column wise?Welcome to SDN.
What you want to do(if I understand correctly) is not possible with the statements available to us. You could do it, but I think it would be a lot of code and I don't think that its worth it. Why exactly do you want to do this?
Regards,
Rich Heilman -
Difference betweem temp table and CTE as performance wise?
Hi Techies,
Can anyone explain CTE and Temp table performance wise. Which is the better object to use while implementing DML operations.
Thanks in advance.
Regards
Cham beeWelcome to the world of performance tuning in SQL Server! The standard answer to this kind of question is:
It depends.
A CTE is a logical construct, which specifies the logical computation order for the query. The optimizer is free to recast computation order in such away that the intermediate result from the CTE never exists during the calculation. Take for instance this
query:
WITH aggr AS (
SELECT account_no, SUM(amt) AS amt
FROM transactions
GROUP BY account_no
SELECT account_no, amt
FROM aggr
WHERE account_no BETWEEN 199 AND 399
Transactions is a big table, but there is an index on account_no. In this example, the optimizer will use that index and only compute the total amount for the accounts in the range. If you were to make a temp table of the CTE, SQL Server would have no choice
to scan the entire table.
But there also situations when it is better to use a temp table. This is often a good strategy when the CTE appears multiple times in the query. The optimizer is not able to pick a plan where the CTE is computed once, so it may compute the CTE multiple times.
(To muddle the waters further, the optimizers in some competing products have this capability.)
Even if the CTE is only referred to once, it may help to materialise the CTE. The temp table has statistics, and those statistics may help the optimizer to compute a better plan for the rest of the query.
For the case you have at hand, it's a little difficult to tell, because it is not clear to me if the conditions are the same for points 1, 2 and 3 or if they are different. But the second one, removing duplicates, can be quite difficult with a temp table,
but is fairly simple using a CTE with row_number().
Erland Sommarskog, SQL Server MVP, [email protected] -
Internal table definition difference
Hello!
I have a doubt about two ways of defining an internal table cos they look alike but i dont really know if the do the same.
First way to define:
DATA: BEGIN OF tvbdpr OCCURS 100.
INCLUDE STRUCTURE vbdpr.
DATA: END OF tvbdpr.
Second way to define:
data: tvbdpr type standard table of vbdpr with header line.
Are they the same?
Regards,
Roberto Okumura.HI,
Technically speaking both are having the same functionality but different technical despription.
I mean.
DATA: BEGIN OF tvbdpr OCCURS 100.
INCLUDE STRUCTURE vbdpr.
DATA: END OF tvbdpr.
the system implicitely creates the header line with the help of key word BEGIN OF.
You need to understand the EXPLICIT Work Aread and IMPLICIT Work Area.
data: tvbdpr type standard table of vbdpr with header line.
The system explicitely creates the header line.
Performance wise better to go for data: tvbdpr type standard table of vbdpr with header line. becuase no need to create work area for doing some other calculations at header line level or work aread level.
DATA: BEGIN OF tvbdpr OCCURS 100.
INCLUDE STRUCTURE vbdpr.
DATA: END OF tvbdpr.
first it recoginze the table vbdpr then allocate the memory area for your internal table.
finally, if you want to define the explicit work area better to go for with header line internal table otherwise go without header line . -
Question about XML mapping to ABAP internal table
Hi experts.
I'm trying to XML mapping. But it doesn't work well. Assume there are XML file as below.
<HEADER>
<ITEM>
<FOO>123</FOO>
<BAR>ABC</BAR>
</ITEM>
<ITEM>
<FOO>456</FOO>
<BAR>DEF</BAR>
</ITEM>
<HEADER>
and I want to trasformation it as below.
ITAB
FOO | BAR
123 | ABC
456 | DEF
How could I trasformation using "call transformation"?
Regards.Hi,
REPORT zind_xml_to_sap NO STANDARD PAGE HEADING.
Data Declaration *
DATA: client TYPE REF TO if_http_client, "Interface
host TYPE string,
port TYPE string,
proxy_host TYPE string,
proxy_port TYPE string,
path TYPE string,
scheme TYPE i,
xml TYPE xstring,
response TYPE string.
DATA: t_xml TYPE smum_xmltb OCCURS 0 WITH HEADER LINE. "XML Table structure used
"for retreive and output XML doc
DATA: g_stream_factory TYPE REF TO if_ixml_stream_factory. "Interface
DATA : return LIKE bapiret2 OCCURS 0 WITH HEADER LINE. "XML Table structure used for retreive
"and output XML doc
Parameters *
PARAMETER : p_add TYPE string LOWER CASE ,
p_dfile LIKE rlgrap-filename.
AT Selection-Screen on value-request for file *
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_dfile.
Get file
PERFORM 100_get_file.
Start-of-Selection *
START-OF-SELECTION.
Perform to upload xml data from URL to SAP internal table
PERFORM 200_xml_upload.
IF t_xml[] IS NOT INITIAL.
Perform to Download data from Internal Table to a text file in local drive
PERFORM 300_download.
write : / 'Data Uploaded to Internal Table Successfully'.
write : / 'XML Data Downloaded to Local path', p_dfile.
else.
write : / 'No Data for upload'.
ENDIF.
*if t_xml[] is INITIAL.
WRITE : address, 'Given URl cannot be Converted' .
else.
LOOP AT t_xml .
WRITE: t_xml-cname, t_xml-cvalue.
ENDLOOP.
endif.
*& Form get_file
Get File
FORM 100_get_file .
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = ' '
IMPORTING
file_name = p_dfile
ENDFORM. " 100_get_file
*& Form 200_xml_upload
form to upload xml data from URL to SAP internal table
FORM 200_xml_upload .
*Check HTTP:// and concatenate
IF p_add NS 'http://' OR p_add NS 'HTTP://'.
CONCATENATE 'http://' p_add
INTO p_add.
ENDIF.
Fetching the address of the URL
CALL METHOD cl_http_client=>create_by_url
EXPORTING
url = p_add
IMPORTING
client = client.
*Structure of HTTP Connection and Dispatch of Data
client->send( ).
*Receipt of HTTP Response
CALL METHOD client->receive
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3
OTHERS = 4.
IF sy-subrc <> 0.
IF sy-subrc = 1.
MESSAGE 'HTTP COMMUNICATION FAILURE' TYPE 'I' DISPLAY LIKE 'E'.
EXIT.
ELSEIF sy-subrc = 2.
MESSAGE 'HTTP INVALID STATE' TYPE 'I' DISPLAY LIKE 'E'.
EXIT.
ELSEIF sy-subrc = 3.
MESSAGE 'HTTP PROCESSING FAILED' TYPE 'I' DISPLAY LIKE 'E'.
EXIT.
ELSE.
MESSAGE 'Problem in HTTP Request' TYPE 'I' DISPLAY LIKE 'E'.
EXIT.
ENDIF.
ENDIF.
Get data of the xml to Response
response = client->response->get_cdata( ).
*FM converting the XML format to abap
CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
text = response
IMPORTING
buffer = xml.
*FM converting XMl to readable format to a internal table.
CALL FUNCTION 'SMUM_XML_PARSE'
EXPORTING
xml_input = xml
TABLES
xml_table = t_xml
return = return.
ENDFORM. " 200_xml_upload
*& Form 300_download
*form to Download data from Internal Table to a text file in local drive
FORM 300_download .
DATA filename TYPE string.
filename = p_dfile.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = filename
WRITE_FIELD_SEPARATOR = 'X'
TABLES
data_tab = t_xml
EXCEPTIONS
FILE_WRITE_ERROR = 1
NO_BATCH = 2
GUI_REFUSE_FILETRANSFER = 3
INVALID_TYPE = 4
NO_AUTHORITY = 5
UNKNOWN_ERROR = 6
HEADER_NOT_ALLOWED = 7
SEPARATOR_NOT_ALLOWED = 8
FILESIZE_NOT_ALLOWED = 9
HEADER_TOO_LONG = 10
DP_ERROR_CREATE = 11
DP_ERROR_SEND = 12
DP_ERROR_WRITE = 13
UNKNOWN_DP_ERROR = 14
ACCESS_DENIED = 15
DP_OUT_OF_MEMORY = 16
DISK_FULL = 17
DP_TIMEOUT = 18
FILE_NOT_FOUND = 19
DATAPROVIDER_EXCEPTION = 20
CONTROL_FLUSH_ERROR = 21
OTHERS = 22
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. -
Reg transfer of data from excel to internal table
hi
i need to upload datas from Excel sheet to Internal Table.For this i use d FM
ALSM_EXCEL_TO_INTERNAL_TABLE.but the problem is if a particular field has no value in excel sheet,then its not uploaded into internal table.then next field value has come to that blank place in d internal table. what i need is if the excel sheet has a blank value for a field then a blank value is added in d inetrnal table also.Use below program logic
Program : ZLWMI151_UPLOAD(Data load to ZBATCH_CROSS_REF Table)
Type : Upload program
Author : Seshu Maramreddy
Date : 05/16/2005
Transport : DV3K919574
Transaction: None
Description: This program will get the data from XLS File
and it upload to ZBATCH_CROSS_REF Table
REPORT ZLWMI151_UPLOAD no standard page heading
line-size 100 line-count 60.
*tables : zbatch_cross_ref.
data : begin of t_text occurs 0,
werks(4) type c,
cmatnr(15) type c,
srlno(12) type n,
matnr(7) type n,
charg(10) type n,
end of t_text.
data: begin of t_zbatch occurs 0,
werks like zbatch_cross_ref-werks,
cmatnr like zbatch_cross_ref-cmatnr,
srlno like zbatch_cross_ref-srlno,
matnr like zbatch_cross_ref-matnr,
charg like zbatch_cross_ref-charg,
end of t_zbatch.
data : g_repid like sy-repid,
g_line like sy-index,
g_line1 like sy-index,
$v_start_col type i value '1',
$v_start_row type i value '2',
$v_end_col type i value '256',
$v_end_row type i value '65536',
gd_currentrow type i.
data: itab like alsmex_tabline occurs 0 with header line.
data : t_final like zbatch_cross_ref occurs 0 with header line.
selection-screen : begin of block blk with frame title text.
parameters : p_file like rlgrap-filename obligatory.
selection-screen : end of block blk.
initialization.
g_repid = sy-repid.
at selection-screen on value-request for p_file.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = g_repid
IMPORTING
FILE_NAME = p_file.
start-of-selection.
Uploading the data into Internal Table
perform upload_data.
perform modify_table.
top-of-page.
CALL FUNCTION 'Z_HEADER'
EXPORTING
FLEX_TEXT1 =
FLEX_TEXT2 =
FLEX_TEXT3 =
*& Form upload_data
text
FORM upload_data.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = p_file
I_BEGIN_COL = $v_start_col
I_BEGIN_ROW = $v_start_row
I_END_COL = $v_end_col
I_END_ROW = $v_end_row
TABLES
INTERN = itab
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
write:/10 'File '.
ENDIF.
if sy-subrc eq 0.
read table itab index 1.
gd_currentrow = itab-row.
loop at itab.
if itab-row ne gd_currentrow.
append t_text.
clear t_text.
gd_currentrow = itab-row.
endif.
case itab-col.
when '0001'.
t_text-werks = itab-value.
when '0002'.
t_text-cmatnr = itab-value.
when '0003'.
t_text-srlno = itab-value.
when '0004'.
t_text-matnr = itab-value.
when '0005'.
t_text-charg = itab-value.
endcase.
endloop.
endif.
append t_text.
ENDFORM. " upload_data
*& Form modify_table
Modify the table ZBATCH_CROSS_REF
FORM modify_table.
loop at t_text.
t_final-werks = t_text-werks.
t_final-cmatnr = t_text-cmatnr.
t_final-srlno = t_text-srlno.
t_final-matnr = t_text-matnr.
t_final-charg = t_text-charg.
t_final-erdat = sy-datum.
t_final-erzet = sy-uzeit.
t_final-ernam = sy-uname.
t_final-rstat = 'U'.
append t_final.
clear t_final.
endloop.
delete t_final where werks = ''.
describe table t_final lines g_line.
sort t_final by werks cmatnr srlno.
Deleting the Duplicate Records
perform select_data.
describe table t_final lines g_line1.
modify zbatch_cross_ref from table t_final.
if sy-subrc ne 0.
write:/ 'Updation failed'.
else.
Skip 1.
Write:/12 'Updation has been Completed Sucessfully'.
skip 1.
Write:/12 'Records in file ',42 g_line .
write:/12 'Updated records in Table',42 g_line1.
endif.
delete from zbatch_cross_ref where werks = ''.
ENDFORM. " modify_table
*& Form select_data
Deleting the duplicate records
FORM select_data.
select werks
cmatnr
srlno from zbatch_cross_ref
into table t_zbatch for all entries in t_final
where werks = t_final-werks
and cmatnr = t_final-cmatnr
and srlno = t_final-srlno.
sort t_zbatch by werks cmatnr srlno.
loop at t_zbatch.
read table t_final with key werks = t_zbatch-werks
cmatnr = t_zbatch-cmatnr
srlno = t_zbatch-srlno.
if sy-subrc eq 0.
delete table t_final .
endif.
clear: t_zbatch,
t_final.
endloop.
ENDFORM. " select_data
Reward points if it is helpful
Thanks
Seshu -
Control statement in internal tables
hi experts,
can any body will provide me the control statement of internal table.
thank youHi,
check this link
http://help.sap.com/saphelp_nw2004s/helpdata/en/9f/db9f1f35c111d1829f0000e829fbfe/content.htm
Control Break Statements
Control break statements are used to create statement blocks which process only specific table lines the LOOP ENDLOOP block.
You open such a statement block with the control level statement AT and close it with the control level statement ENDAT. The syntax is as follows:
Table should be sorted when you use control-break statements
You can break the sequential access of internal tables by using these statements.
Syntax:
At first.
<Statement block>
Endat.
This is the first statement to get executed inside the loop (remember control break statements are applicable only inside the loop)
So in this block you can write or process those statements which you want to get executed when the loop starts.
At New carrid.
Write:/ carrid.
Endat.
In this case whenever the new carrid is reached, carrid will be written.
At End of carrid.
Uline.
Endat.
In this case whenever the end of carrid is reached, a line will be drawn.
At Last.
Write:/ Last Record is reached.
Endat.
Processing of statements within this block is done when entire processing of entire internal table is over. Usually used to display grand totals.
You can use either all or one of the above control break statements with in the loop for processing internal table.
At end of carrid.
Sum.
Endat.
In above case the statement SUM (applicable only within AT-ENDAT) will sum up all the numeric fields in internal table and result is stored in same internal table variable.
Regards,
Sruthi -
Hi Experts,
Row
Column
Value
1
0001
Prem(First Name )
1
0002
Raj(Middle name )
1
0003
Kaushik(Last name
2
0001
Naresh
I have the above data in excel file and my internal table like as follows
Data : begin of it_itab occurs 0,
Row type c,
Column type string,
Value type string,
End of it_itab.
Now I want to upload the excel file to my internal table
filed wise i.e in my intenal table row
shold have row values from excel same as
for column and value also
Can anyone suggest me fix this issue?
Best Regards,
Ramjee MYou may use this function to put data in internal table.
CALL FUNCTION 'KCD_EXCEL_OLE_TO_INT_CONVERT'
EXPORTING
filename = p_file *xcel file name
i_begin_col = p_scol *start column
i_begin_row = p_srow *start row
i_end_col = p_ecol *end col
i_end_row = p_erow *end row
TABLES
intern = it_tab
EXCEPTIONS
inconsistent_parameters = 1
upload_ole = 2
OTHERS = 3.
Use this function to put data in internal table.
Maybe you are looking for
-
My home button on my ipod touch is not working.
My home button on my ipod touch 4g does not work right. You have to press REALLY hard for it to do anything it is not sensitive at all. And the button is pressed down in and doesnt feel right iPod touch, iOS 4.2.1
-
I clicked "upgrade" for the new version of Keynote in the Apps Store. Now it says "Installed", but it's still the old (5.3) version on my computer. Now what?
-
Switch statesment in return statement
Hello, how do i effectively use a switch statement in a method that returns a string, below is my understanding but this implementation will not compile public String toString(int format){ return switch(format){ case 0:
-
TS1544 tried to reset my keychain password but says 'unable to obtain..'? HELP
Yeah so basically I don't understand what my keychain password would be and why it suddenly keeps asking me for one? and won't let me change it
-
WF_DOC or SOFM to document in DMS.
Hello all. I have a workflow that at some point has an instance of a workflow document (MS Word), Object type WF_DOC. It is possible to convert that to a SOFM object instance. I want to be able to create a document in DMS and place this MS Word file