ABAP code issue
Hello Team,
We are facing ABAP coding performance issue in BW production and quality system. This is holding under production data loading.
There is piece of code written in BW while loading data from one target to other
Code:
DELETE SOURCE_PACKAGE WHERE recordmode = 'X' OR recordmode = 'R'
OR recordmode = 'D'.
SELECT * INTO CORRESPONDING FIELDS OF TABLE it_new_source
FROM /bic/afao06pa100
FOR ALL ENTRIES IN SOURCE_PACKAGE
where /bic/fcckjobno = SOURCE_PACKAGE-/bic/fcckjobno
and /bic/fcckjitid = SOURCE_PACKAGE-/bic/fcckjitid.
* Since the preceding tranformation in the data flow already aggregates
*multiple occurences of single SO into one record the deletion of
*duplicates
* is obsolete
* SORT SOURCE_PACKAGE BY doc_number ASCENDING s_ord_item ASCENDING
* record DESCENDING.
* delete ADJACENT DUPLICATES FROM SOURCE_PACKAGE COMPARING doc_number
* s_ord_item.
SORT SOURCE_PACKAGE BY /bic/fcckjobno /bic/fcckjitid.
LOOP AT it_new_source INTO wa_new_source.
READ TABLE SOURCE_PACKAGE WITH KEY
/bic/fcckjobno = wa_source-/bic/fcckjobno
/bic/fcckjitid = wa_source-/bic/fcckjitid
BINARY SEARCH
INTO wa_source.
IF sy-subrc = 0.
MOVE-CORRESPONDING wa_new_source TO ls_target_key.
MOVE-CORRESPONDING wa_source TO wa_new_source.
MOVE-CORRESPONDING ls_target_key TO wa_new_source.
MODIFY it_new_source FROM wa_new_source.
ENDIF.
ENDLOOP.
REFRESH SOURCE_PACKAGE.
SOURCE_PACKAGE[] = it_new_source[].
REFRESH it_new_source.
Above code takes long time for execution.
In production for 3930891 number or records it runs for an hour an hour and goes into infinite loop without loading any data.
We have tried same data load in quality system. (BR1)
For 68293 records load has executed for 8-9 hours and then completed successfully.
I have tried editing code in BR1 system by removing ‘INTO CORRESPONDING FIELDS OF TABLE’ and written plain selection of all fields. Performed ST05 trace by commenting other code. But still found it is taking time at select statement and not improvement in load run time at start routine.
Also tried editing select statement like below but it took same time:
SELECT /BIC/FCCKCANC PCA_DOCTYP PCA_DOCNO PCA_ITEMNO CHRT_ACCTS MATERIAL
ACCOUNT COMP_CODE CO_AREA PROFIT_CTR VERSION PART_PRCTR FISCPER
FISCVARNT /BIC/FCCKJITID /BIC/FCCKJOBNO RECORDMODE /BIC/FCCKCNTR
/BIC/FCCKCNTN /BIC/FCCKEXIMP /BIC/FCCKJOBTP
/BIC/FCCKINTST /BIC/FCCKMAJBN /BIC/FCCKALST /BIC/FCCHUBIND
/BIC/FCCSFCLDT /BIC/FCCHDCLDT /BIC/FCCKETADT /BIC/FCCKETDDT
/BIC/FCCFULFDT /BIC/FCCKHBL /BIC/FCCKCBL /BIC/FCCKJCRBY /BIC/FCCKLCRBY
INTO TABLE it_new_source
FROM /bic/afao06pa100
FOR ALL ENTRIES IN SOURCE_PACKAGE
where /bic/fcckjobno = SOURCE_PACKAGE-/bic/fcckjobno
and /bic/fcckjitid = SOURCE_PACKAGE-/bic/fcckjitid.
Please suggest code improvement.
Any data base improvement for tables?
Any indexing improvement for tables?
If required please get in touch with data base team for same.
LOOP AT it_new_source INTO wa_new_source.
do.
READ TABLE SOURCE_PACKAGE
INDEX W_TABIX
INTO wa_source.
IF SY-SUBRC NE SPACE.
EXIT.
ENDIF.
IF wa_new_source-/bic/fcckjobno lt wa_source-/bic/fcckjobno.
exit.
elseif wa_new_source-/bic/fcckjobno EQ wa_source-/bic/fcckjobno.
MOVE-CORRESPONDING wa_new_source TO ls_target_key.
MOVE-CORRESPONDING wa_source TO wa_new_source.
MOVE-CORRESPONDING ls_target_key TO wa_new_source.
MODIFY it_new_source FROM wa_new_source.
EXIT.
elseif wa_new_source-/bic/fcckjobno gt wa_source-/bic/fcckjobno.
w_tabix = w_tabix + 1.
endif.
ENDIF.
DONE.
ENDLOOP.
I put only for one field control, you must add the second field in the logic.
With this kind of code you read only 1 time the two tables.
This code comes from an old age name : R/2
regards
Fred
Similar Messages
-
Enhancement-ABAP Code-Customized Field issue
Hi Experts,
Currently I am working on the BW3.5 version. We are using the standard SRM standard extractor 0BBP_TD_SC_1 and we enhance same extractor(populate the filed through CMOD - ABAP Code) with one customized field also. We are having issue on the customized field data which post from SRM system. I have verified the field value and value is fine in RSA3 in SRM source system. But while posting into the BW(PSA itself), its loading correct & wrong value. When i check the PSA for the particular load, It looks little strange. In the PSA, I can see correct value on my first record of the same SC and then next records has incorrect value of the same SC. Currently I am using the ODS as a data target. So finally i am getting the incorrect value on the customized field.
Ex Scenario:
Ex Customized Field: ZORGID
In SRM source system RSA3 Extractor Checker value:
Shopping Card No: 100
Customized Field: ZORGID=1
Shopping Card No: 200
Customized Field: ZORGID=2
In BW posting-PSA:
Shopping Card No: 100
Customized Field: ZORGID=2
Shopping Card No: 200
Customized Field: ZORGID=2
At the same time, if i do the selective deletion of the particular Shopping Card or group of SC in BW and do the full repair, then it gets a correct ZORGID=1 for the same Shopping Card.
I strongly believe, something wrong in the ABAP code. But when we tried to debug the customized filed value in RSA3. The value is fine. so we unable to trace out the issue. Please help me to fix the code. Thanks in advance.
CMOD ABAP Code:
*Populate approver ID even though it doesn't require approval this is required to make sure BW reports have restrict access to respective Org Unit approvals only
IF l_s_bbp_sc-approver_id IS INITIAL AND l_s_bbp_sc-itm_guid IS NOT INITIAL.
CALL FUNCTION 'Z_BBP_FIRST_APPROVALGET'
EXPORTING
iv_header_guid = l_s_bbp_sc-guid
iv_itm_guid = l_s_bbp_sc-itm_guid
IMPORTING
approver_no = l_s_bbp_sc-approver_id
EXCEPTIONS
no_data = 1
OTHERS = 2
IF sy-subrc 0.
ENDIF.
ENDIF.
To ensure that the Org Unit passed in into the field
l_s_bbp_sc-zzapprov_orgunit belongs to the Actual Level 1
Budget Owner and not any other manager such as Added Approver.
CLEAR : ls_ln_approvers, l_userid, lv_bpartner_guid.
DATA : lv_f_apprv_part TYPE BU_PARTNER.
READ TABLE lt_ln_approvers INTO ls_ln_approvers
WITH KEY INITIAL_INDEX = '0000000001'.
IF sy-subrc EQ 0.
MOVE ls_ln_approvers-approval_agent+2(12) TO l_userid.
CALL FUNCTION 'BP_CENTRALPERSON_GET'
EXPORTING
iv_username = l_userid
IMPORTING
ev_bu_partner_guid = lv_bpartner_guid
EXCEPTIONS
no_central_person = 1
no_business_partner = 2
no_id = 3
OTHERS = 4.
IF sy-subrc = 0.
CALL FUNCTION 'BUPA_NUMBERS_GET'
EXPORTING
iv_partner_guid = lv_bpartner_guid
IMPORTING
ev_partner = lv_f_apprv_part.
ENDIF.
ENDIF.
We get the BP number of the first Budget Owner 1
Here, we superseed the field l_s_bbp_sc-approver_id
whereby it may be wrong due to Added Approver.
IF l_s_bbp_sc-approver_id IS NOT INITIAL.
IF lv_f_apprv_part IS NOT INITIAL.
IF l_s_bbp_sc-itm_guid IS NOT INITIAL.
CALL FUNCTION 'RH_STRUC_GET'
EXPORTING
act_otype = 'BP'
act_objid = lv_f_apprv_part
act_wegid = 'EBP-UP'
act_begda = sy-datum
act_endda = sy-datum
act_tdepth = 4
TABLES
result_tab = lt_result_tab
EXCEPTIONS
no_plvar_found = 1
no_entry_found = 2
OTHERS = 3
IF sy-subrc = 0.
READ TABLE lt_result_tab INTO ls_result_tab WITH KEY
otype = 'O'.
IF sy-subrc EQ 0.
l_s_bbp_sc-zzapprov_orgunit = ls_result_tab-objid.
ELSE.
ENDIF.
ENDIF.
ENDIF.
Thanks,
RRHi Experts,
Any suggestions. Thanks.
Thanks,
RR -
Abap Code TO ENHANCE DATASOURCE with KEY FIELD OF SOURCE TABLE
Dear Friends, Please help me to resolve this important issue at my end.
<b>Requirement</b>: enhance the STRUCTURAL data source which is
based on the table VISTSU , now this table has a <b>key INTERNO</b> (Data Element : SECAINTRENO) which i want to enhance in datasource
SGONR = STRUCTURAL NUMBER present in extract structure of datasource
Solution: I am not able to see any records for zzinterno enhance field in datasource rsa3 (Extractor CHECKER). Can u help me correct the ABAP code or tell me the way to pull the records for ZZINTERNO from VISTSU table.
Thanks
Poonam Roy
ABAP Code
data: l_s_REIS_STRUCTURAL_ATTR like REIS_STRUCTURAL_ATTR.
case i_datasource.
WHEN '0STRUCTURAL_ATTR'.
loop at C_t_data into l_s_REIS_STRUCTURAL_ATTR.
l_tabix = sy-tabix.
clear I_VISTSU .
select single * from VISTSU into i_VISTSU where SG0NR = l_s_REIS_STRUCTURAL_ATTR-SGONR.
if sy-subrc = 0.
l_s_REIS_STRUCTURAL_ATTR-ZZINTRENO = I_VISTSU -INTRENO.
modify C_t_data from l_s_REIS_STRUCTURAL_ATTR index l_tabix.
endif.
endloop.
endcase.Try the below code.
data: l_s_REIS_STRUCTURAL_ATTR like REIS_STRUCTURAL_ATTR.
data: temp_interno like VISTSU -INTRENO.
data: h_tabix LIKE sy-tabix.
case i_datasource.
WHEN '0STRUCTURAL_ATTR'.
loop at C_t_data into l_s_REIS_STRUCTURAL_ATTR.
MOVE SY-TABIX TO H_TABIX.
clear temp_interno.
select single INTERNO from VISTSU into temp_interno where SG0NR = l_s_REIS_STRUCTURAL_ATTR-SGONR.
if sy-subrc = 0.
l_s_REIS_STRUCTURAL_ATTR-ZZINTRENO = temp_interno.
endif.
modify C_t_data from l_s_REIS_STRUCTURAL_ATTR index H_TABIX.
ENDLOOP.
ENDCASE.
Regards, Siva -
LKM SAP BW to Oracle (SQLLDR) generates sintax error in ABAP code.
Hi Experts,
We are installing a SAP BW KM's in ODI 11g.
Actually, we are able to make reverse ingeneering succesfully.
Now we want to use the LKM in order to extract SAP data.
The KM fails, in step Generate ABAP Code. The code is uploaded to SAP system but with sintaxis errors.
That's the beginning of the SAPAbapExecuteOpenTool_8001_7001.log.
+##################################################+
+############ Open Tool Logger ####################+
+##################################################+
+############ Upload value: 1+
+############ Execute value: 1+
+############ BASE RKM FLAG: 0+
+############ ZRFC_RUN_INSTALL: 1+
+############ Abap Function Name: ZODI_8001_7001+
+############ Sap Host Name: XXXXXXXX+
+############ Sap User Name: XXXX+
+############ Sap password: ********+
+############ Sap Client: 100+
+############ Sap language: ES+
+############ Sap system no: 00+
+############ Sap Connection Pool Name: SAP_ODI_LKM_POOL_GLOBAL+
+############ Sap Connection Pool Size: 10+
+############ Sap Function group name: ZODIBW_LKM_FGRP+
+############ File Delimiter:+
+############ File Name: ZODI_8001_7001.txt+
+############ FTP Host: XXXXXXXXX+
+############ FTP User: ftpbi+
+############ FTP Password: ********+
+############ FTP Passive Mode: 1+
+############ FTP Transfer Time out: 100000+
+############ User abap parameter names: IV_DELIMITER,CHAR1;IV_FILENAME,CHAR255;IV_USER,CHAR35;IV_PWD,CHAR35;IV_HOST,CHAR35;IV_HASHVALUE,CHAR35;IV_PATH,CHAR35;IV_REQUID_L,RSSID;IV_REQUID_H,RSSID+
+############ Abap rfc table parameters: RETURN,BAPIRETURN;ET_FILE_RETURN,BAPIRET2+
+############ Log File Name: /tmp/SAPAbapExecuteOpenTool_8001_7001.log+
+############ OpenHub Path: /tmp/+
+############ Delta Extraction First Request ID : 0+
+############ Delta Extraction Last Request ID : 0+
+############ SAP Development Class : ZODIBW_PCKG+
+############ Max Row Count :+
+############ Fetch Batch Size :+
+############ Hash Value Marker: HVM+
+############ Generated Program:+
*** ODS DSO extraction
TYPES: BEGIN OF ty_final,
+/BIC/AZOFI_UTE00_/BIC/ZFI_SOCOR+
TYPE
+/BIC/AZOFI_UTE00-/BIC/ZFI_SOCOR,+
+/BIC/AZOFI_UTE00_SOURSYSTEM+
TYPE
+/BIC/AZOFI_UTE00-SOURSYSTEM,+
END OF ty_final.
In the SAP GUI shows a sintaxis error.
Functions Module ZODI_8001_7001. line 25
The name "/BIC/AZOFI_UTE00_/BIC/ZFI_SOCOR" is longer that allowed.
+30 characters.+
Really the TYPE "/BIC/AZOFI_UTE00_/BIC/ZFI_SOCOR" has 31 characters.
The sufix "/BIC/" is the "NAMESPACE", a SAP grouping concept.
AZOFI_UTE00 is a table name.
ZFI_SOCOR is a column name.
Are this sufix correct in the APAP code?
Has anyone had that problem?
Any comment will be wellcome.
Thank's in advance.Hi Somchai,
r U able to resolve ur issue ..........i'm also struck there at the same point.
I am using shared folder for file transfer and my error message is
java.lang.RuntimeException: Error occured in open tool execute method...Error in executing ABAP program...Error in executing ABAP program...Error occurred when creating dataset\\<hostname>\bi-interface$\ZODI_11001_12001_GLOBAL.txt
Thanks.
Edited by: Drona on Mar 26, 2012 7:25 AM -
Need ABAP code for the below Services requirement
Hi,
We have a requirement to show all the services for a particular Purchase order number.For this I built a view on 2 tables ESLL and EKPO.Now based on the below logic I need to bring the services for the Purchase order..
1.Enter PO number,item no. and Doc category in EKPO and find the Pack no.
2.Now take the Pack no. of EKPO and give in ESLL and find the Sub pack no.
3.Now take this Subpack no. and Give this sub pack as Pack no. in ESLL
4.This will be the Service entry record for that PO number.
Can any one Please suggest me to how to write the ABAP code for the above logic.
Thanks & Regards,
DinakarHi Dinaker,
Did you find any solution for this issue. I too have a similar requirement of pulling all the service orders for a specific Purchase Order in the BW report.
Thanks,
SAPBWI -
Unwanted ABAP Code Block Triggering - IF condition not working
Friends,
I am facing weird issue in my production system i.e. one of the code block which was bounded in IF condition is getting triggered. However, as per the data that I have in my system this IF condition should skip that code block.
Let me give you code and execution flow here:
I have Program A in which I am submitting Program B in background mode to selected server. This Program A will be executed by end user in Background mode.
call function 'JOB_OPEN'
exporting
jobname = job_name
importing
jobcount = job_number
exceptions
cant_create_job = 01
invalid_job_data = 02
jobname_missing = 03.
if sy-subrc = 0.
submit program B
via job job_name number job_number
with p_sched = sched
with period_p = period
with fyear_p = fyear
with username = ruser
and return.
call function 'JOB_CLOSE'
exporting
jobcount = job_number
jobname = job_name
sdlstrtdt = start_date
sdlstrttm = start_time
targetserver = l_targetserver "V05++
exceptions
cant_start_immediate = 01
invalid_startdate = 02
jobname_missing = 03
job_close_failed = 04
job_nosteps = 05
job_notex = 06
lock_failed = 07.
endif.
As you can see in code, I am passing job to run on l_targetserver. This program also releases some other jobs on other programs.
In Program B, I have code like this:
Top Include.
start-of-selection.
perform routine1 using p_fyear. "THIS HAS SOME SELECT QUERIES AND OTHER CODE and THERE IS NO ISSUE WITH IT. THIS ROUTINE IS
ALSO HAVING ONE AND ONLY 'CLEAR' statement on DELTA_FLAG.
perrform routine2.
form routine2.
loop itab into wa. " This itab was populated in routine1
perform get_flag." WE ARE PASSING VALUE TO DELTA_FLAG VARIABLE HERE. YOU CAN CHECK CODE BELOW.
perform process_data. "CHECK THIS ROUTINE
peform update_records.
endloop.
endform.
Form Get_FLag.
select * from dbtable into localtable where <condition>. " THIS QUERY RETURNS SOME DATA AND MY FLAG WILL BE SET AS 'X'.
if sy-subrc = 0.
delta_flag = 'X'. "THis one declared in top include.
endif.
EndForm.
Form Process_Data.
Perform get_dataset1.
while counter <> 0. " Variable Counter declared in top include and default value is 20. Value will be decreased in side this loop. No issues with it.
if wa-fld1 = '1'. "Check value of one of the field.
continue.
endif.
perform get_delta_data. " We have Unwanted ABAP code (for my scenario) here.
endwhile.
Endform.
form update_records.
call function 'FUNCTION' in update task exporting par1 = itab.
commitwork
endform.
form get_delta_data.
if delta_flag is initial.
select data from BSEG into i_bseg where <condition>. " This query is getting triggered in my system.
endif.
endform.
All my data objects were declared in Top include of the program. Subroutines with their parameters were same as above code. I am not using any sub-routine second time or out-side of this program. As shown, this program updates records to one of the table with UPDATE function module IN UPDATE TASK and there is COMMITWORK after that. This task is part of
As you could understand, DELTA_FLAG is having 'X' but query on BSEG is getting triggered. We are not clearing this variable after populating 'X' to it. I can see this query from Program B captured in ST12 trace results. (Verified it multiple times)
I did this analysis:
1. Ran this process in foreground with debugging, then there is no issue.
2. Debugged 'Finished' job of my production system, but I dont see this code triggered in Debug mode.
3. Replicated same execution process in our non-production environments, but there is no issue.
Let me know if you need any other details.
Thanks for your time.
Regards,
NaveenI forgot the one bit, which might actually have been useful: I'd be moving the if delta_flag is initial. out of form get_delta_data, before perform get_delta_data.Since you are calling in nested loops there, every little bit of run-time counts, and "philosophically" I feel - procedure should do what its name promises it will, and not check whether it's "appropriate time" to do it
cheers and good luck
Jānis -
Hi ppl,
I am a bit confused.If i have to make some field to only 'display'(so that the user has no choice to edit),how can i do it?
-Who provides these templates??These templates that we publish are written in ABAP,right?
-Can we create our own templates and publish??
**When they say,change the template or change the ABAP code..what does it mean?Because to check the templates we goto SE80 and to change the code/add a field/edit a field--we go to SE11.Please let me know the link between SE11 and SE80 or the difference.
Many Thanks
SamSam,
Before changing a template please go through following,it may resolve your issue -
In this BAdI you can change the screen variant that controls the display of the item overviews and search results. As default, the following screen variants are called up:
· Item data overview in the invoice without purchase order reference: Screen variant BBP_IV_NON_PO
Method GET_SCREENVARIANT_INV
· Item data overview in the invoice with purchase order reference: Screen variant BBP_IV
Method GET_SCREENVARIANT_INV
· Item data overview in the confirmation: Screen variant BBP_CF
Method GET_SCREENVARIANT_CONF
· Item data overview in the confirmation for time recording: Screen variant BBP_CF_TIMEREC
Method GET_SCREENVARIANT_CONF
· Item data overview in the purchase order: Screen variant BBP_PO
Method GET_SCREENVARIANT_PO
· Item overview for contracts: Screen variant BBP_CTR_ITEMLIST
Method GET_SCREENVARIANT_CTR
· Item overview for contract selection: Screen variant BBP_CTR_ITEM_SELLIST
Method GET_SCREENVARIANT_CTR
· Search results for creating an invoice and/or confirmation: Screen variant BBP_SEARCH_PO
Method GET_SCREENVARIANT_SEARCH
· Search results for creating a purchase order: Screen variant BBP_SEARCH_SC
Method GET_SCREENVARIANT_SEARCH
· Search results for displaying/changing an invoice: Screen variant BBP_CHANGE_IV
Method GET_SCREENVARIANT_SEARCH
· Search results for displaying/changing a confirmation: Screen variant BBP_CHANGE_CF
Method GET_SCREENVARIANT_SEARCH
· Item overview for creating/displaying/processing/status of a shopping cart: Screen variant BBP_SC
Method GET_SCREENVARIANT_SC
· Worklist for Sourcing: Screen variant BBP_SOCO_WL
Method GET_SCREENVARIANT_SOCO
· Work area in Sourcing: Screen variant BBP_SOCO_GA
Method GET_SCREENVARIANT_SOCO
Activities
If you wish to hide or show fields, proceed as follows:
1. Determine the screen variant, for example, BBP_IV, using the list above.
2. Copy this screen variant, for example, in ZZ_BBP_IV_1, in Transaction SHD0.
3. Change the new screen variant as required. Note that you can only change the display properties for fields of table controls. You can switch the display on and off (column Invisible in Transaction SHD0). You can recognize the fields of a table control because they have a 1 on the right side of the first column. In addition, the heading for this area contains (Table CTRL.
4. Implement the appropriate method (see the list above). Fill the export parameter EV_SCVARIANT with the new screen variant.
You can create multiple screen variants for a screen and then select these in the BAdI depending on the user or on other criteria.
Thanks and Warm Regards.
Pras -
Abap code for sap exit variables?
Hi,
i) Where can I find the abap code for SAP exit variables
OP_KEYDT used for the net due date
OP_KEYD2 used for the posting date
OP_KEYD3 used for the clearing date, which are used in FI AR aging report(0FIAR_C03).
Based on the Net Due Date, which is key date(0NETDUEDATE), entered by the user at runtime, the posting date and celaring date are populated.
II) The problem is we want to simulate a similar scenario, but with key date, which user enters is based on the custom Net Due Date(ZNETDUEDATE).And this date is populated to posting date and clearing date variables.
How do we acheive that.
Thanks.Please tell how u solved ur issue i have the same scenario to be do.
-
Dear Experts,
In the below abap code i am facing the problem of goods returns and other issues.
becoz of that my code add the qty & value of that invoices.
please give me suggestion.
Please go through the bold area.
SELECT-OPTIONS : s_spart FOR vbrk-spart,
s_kunag FOR vbrk-kunag,
s_fkdat FOR vbrk-fkdat OBLIGATORY.
*--end of selection--
SELECT vbrk~spart
vbrk~vbeln
vbrk~kunag
vbrk~kurrf
vbrk~netwr
vbrk~fkdat
vbrp~mwsbp
vbrp~fkimg
vbak~auart
INTO CORRESPONDING FIELDS OF TABLE i_vbrk
FROM vbrk
INNER JOIN vbrp
ON vbrpvbeln = vbrkvbeln
INNER JOIN vbak
on vbakvbeln = vbrpaubel
WHERE vbrk~spart IN s_spart
AND vbrk~kunag IN s_kunag
AND vbrk~fkdat IN s_fkdat
AND VBRK~VBTYP IN ('M','O','P')
AND vbrk~vkorg = 'JS01'
AND vbrk~fksto NE 'X'
AND vbrk~rfbsk = 'C'.
SELECT knkk~kunnr
knkk~klimk
kna1~name1
INTO CORRESPONDING FIELDS OF TABLE i_knkk
FROM knkk
INNER JOIN kna1
ON knkkkunnr = kna1kunnr
WHERE kna1~kunnr IN s_kunag.
LOOP AT i_vbrk.
IF i_vbrk-auart = 'ZJCR' OR i_vbrk-auart = 'ZJDR' OR i_vbrk-auart = 'ZJC1'.
CLEAR i_vbrk-fkimg.
clear i_vbrk-vlinr.
ENDIF.
IF i_vbrk-mwsbp <> 0.
i_vbrk-netwr = i_vbrk-netwr + i_vbrk-mwsbp.
ENDIF.
IF i_vbrk-kurrf <> 1.
*i_vbrk-vlinr = i_vbrk-netwr * i_vbrk-kurrf.*
ELSE.
i_vbrk-vlinr = i_vbrk-netwr.
ENDIF.
IF i_vbrk-auart = 'ZJRE'
OR i_vbrk-auart = 'ZJCR'
OR i_vbrk-auart = 'ZJC1'
OR i_vbrk-auart = 'ADTC'
OR i_vbrk-auart = 'ZJR1'
OR i_vbrk-auart = 'ZJKR'
OR i_vbrk-auart = 'ZJBR'.
it_main-netwr = it_main-netwr * -1.*
*i_vbrk-vlinr = i_vbrk-vlinr * -1.*
*i_vbrk-fkimg = i_vbrk-fkimg * -1.*
ENDIF.
CLEAR :i_vbrk-mwsbp, i_vbrk-netwr, i_vbrk-kurrf." i_vbrk-fkimg.
MODIFY i_vbrk. "INDEX V_INDEX.
ENDLOOP.
LOOP AT i_vbrk.
MOVE I_VBRK-KUNAG TO I_FINAL-KUNNR.
MOVE I_VBRK-FKDAT TO I_FINAL-FKDAT.
MOVE I_VBRK-FKIMG TO I_FINAL-FKIMG.
clear i_vbrk-auart.
IF i_vbrk-fkdat+4(02) = '01'.
i_KNKK-month = 'JAN'.
i_vbrk-janq = i_vbrk-fkimg.
i_vbrk-jana = i_vbrk-vlinr / 100000.
ENDIF.
IF i_vbrk-fkdat+4(02) = '02'.
i_KNKK-month = 'FEB'.
i_vbrk-febq = i_vbrk-fkimg.
i_vbrk-feba = i_vbrk-vlinr / 100000.
ENDIF.
IF i_vbrk-fkdat+4(02) = '03'.
i_KNKK-month = 'MAR'.
i_vbrk-marq = i_vbrk-fkimg.
i_vbrk-mara = i_vbrk-vlinr / 100000.
ENDIF.
IF i_vbrk-fkdat+4(02) = '04'.
i_KNKK-month = 'APR'.
i_vbrk-aprq = i_vbrk-fkimg.
i_vbrk-apra = i_vbrk-vlinr / 100000.
ENDIF.
IF i_vbrk-fkdat+4(02) = '05'.
i_KNKK-month = 'MAY'.
i_vbrk-mayq = i_vbrk-fkimg.
i_vbrk-maya = i_vbrk-vlinr / 100000.
ENDIF.
IF i_vbrk-fkdat+4(02) = '06'.
i_KNKK-month = 'JUN'.
i_vbrk-junq = i_vbrk-fkimg.
i_vbrk-juna = i_vbrk-vlinr / 100000.
ENDIF.
IF i_vbrk-fkdat+4(02) = '07'.
i_KNKK-month = 'JUL'.
i_vbrk-julq = i_vbrk-fkimg.
i_vbrk-jula = i_vbrk-vlinr / 100000.
ENDIF.
IF i_vbrk-fkdat+4(02) = '08'.
i_KNKK-month = 'AUG'.
i_vbrk-augq = i_vbrk-fkimg.
i_vbrk-auga = i_vbrk-vlinr / 100000.
ENDIF.
IF i_vbrk-fkdat+4(02) = '09'.
i_KNKK-month = 'SEP'.
i_vbrk-sepq = i_vbrk-fkimg.
i_vbrk-sepa = i_vbrk-vlinr / 100000.
ENDIF.
IF i_vbrk-fkdat+4(02) = '10'.
i_KNKK-month = 'OCT'.
i_vbrk-octq = i_vbrk-fkimg.
i_vbrk-octa = i_vbrk-vlinr / 100000.
ENDIF.
IF i_vbrk-fkdat+4(02) = '11'.
i_KNKK-month = 'NOV'.
i_vbrk-novq = i_vbrk-fkimg.
i_vbrk-nova = i_vbrk-vlinr / 100000.
ENDIF.
IF i_vbrk-fkdat+4(02) = '12'.
i_KNKK-month = 'DEC'.
i_vbrk-decq = i_vbrk-fkimg.
i_vbrk-deca = i_vbrk-vlinr / 100000.
ENDIF.
MODIFY i_KNKK.
MODIFY i_vbrk. "INDEX V_INDEX.
ENDLOOP.
CLEAR : i_VBRK-FKDAT, i_vbrk-vbeln.
DATA : ii_vbrk LIKE i_vbrk OCCURS 0 WITH HEADER LINE.
LOOP AT i_VBRK.
CLEAR : i_VBRK-FKDAT, i_vbrk-vbeln,i_vbrk-auart.
COLLECT i_vbrk INTO ii_vbrk.
MODIFY i_VBRK.
ENDLOOP.
*LOOP AT i_knkk.
IF i_final-kunag = knkk-kunnr.
APPEND i_final.
ENDIF.
*ENDLOOP.
DATA : V(3) TYPE C.
CLEAR v_index.
LOOP AT ii_vbrk.
v_index = sy-TABIX.
READ TABLE i_knkk WITH KEY kunnr = ii_vbrk-kunag.
IF SY-SUBRC = 0.
MOVE i_knkk-klimk TO ii_vbrk-klimk.
MOVE i_knkk-name1 TO ii_vbrk-name1.
MOVE I_KNKK-MONTH TO II_VBRK-MONTH.
MODIFY ii_vbrk INDEX v_index.
ENDIF.
ENDLOOP.
LOOP AT ii_vbrk.
ii_vbrk-klimk = ii_vbrk-klimk / 100000.
II_VBRK-VLINR = II_VBRK-jana + II_VBRK-feba + II_VBRK-mara + II_VBRK-apra + II_VBRK-maya + II_VBRK-juna + II_VBRK-jula + II_VBRK-auga + II_VBRK-sepa + II_VBRK-octa + II_VBRK-nova + II_VBRK-deca.
PEAK_QTY = II_VBRK-JANQ.
PEAK_AMT = II_VBRK-JANA.
PEAK_MONTH = 'JAN'.
IF PEAK_AMT LT II_VBRK-FEBA.
PEAK_QTY = II_VBRK-FEBQ.
PEAK_AMT = II_VBRK-FEBA.
PEAK_MONTH = 'FEB'.
ENDIF.
IF PEAK_AMT LT II_VBRK-MARA.
PEAK_QTY = II_VBRK-MARQ.
PEAK_AMT = II_VBRK-MARA.
PEAK_MONTH = 'MAR'.
ENDIF.
IF PEAK_AMT LT II_VBRK-APRA.
PEAK_QTY = II_VBRK-APRQ.
PEAK_AMT = II_VBRK-APRA.
PEAK_MONTH = 'APR'.
ENDIF.
IF PEAK_AMT LT II_VBRK-MAYA.
PEAK_QTY = II_VBRK-MAYQ.
PEAK_AMT = II_VBRK-MAYA.
PEAK_MONTH = 'MAY'.
ENDIF.
IF PEAK_AMT LT II_VBRK-JUNA.
PEAK_QTY = II_VBRK-JUNQ.
PEAK_AMT = II_VBRK-JUNA.
PEAK_MONTH = 'JUN'.
ENDIF.
IF PEAK_AMT LT II_VBRK-JULA.
PEAK_QTY = II_VBRK-JULQ.
PEAK_AMT = II_VBRK-JULA.
PEAK_MONTH = 'JUL'.
ENDIF.
IF PEAK_AMT LT II_VBRK-AUGA.
PEAK_QTY = II_VBRK-AUGQ.
PEAK_AMT = II_VBRK-AUGA.
PEAK_MONTH = 'AUG'.
ENDIF.
IF PEAK_AMT LT II_VBRK-SEPA.
PEAK_QTY = II_VBRK-SEPQ.
PEAK_AMT = II_VBRK-SEPA.
PEAK_MONTH = 'SEP'.
ENDIF.
IF PEAK_AMT LT II_VBRK-OCTA.
PEAK_QTY = II_VBRK-OCTQ.
PEAK_AMT = II_VBRK-OCTA.
PEAK_MONTH = 'OCT'.
ENDIF.
IF PEAK_AMT LT II_VBRK-NOVA.
PEAK_QTY = II_VBRK-NOVQ.
PEAK_AMT = II_VBRK-NOVA.
PEAK_MONTH = 'NOV'.
ENDIF.
IF PEAK_AMT LT II_VBRK-DECA.
PEAK_QTY = II_VBRK-DECQ.
PEAK_AMT = II_VBRK-DECA.
PEAK_MONTH = 'DEC'.
ENDIF.
II_VBRK-VLINR = II_VBRK-jana + II_VBRK-feba + II_VBRK-mara + II_VBRK-apra + II_VBRK-maya + II_VBRK-juna + II_VBRK-jula + II_VBRK-auga + II_VBRK-sepa + II_VBRK-octa + II_VBRK-nova + II_VBRK-deca.
II_VBRK-FKIMG = PEAK_QTY.
II_VBRK-peaka = PEAK_AMT.
II_VBRK-MONTH = PEAK_MONTH.
MODIFY II_VBRK.
ENDLOOP.
SORT ii_vbrk BY SPART.
Thanks
DSRAJPUTHi,
could you please try to format your coding nicely (see Markup Possibilities). There is also a possibility to attach files.
BR,
Tomislav -
ABAP Code to delete old PSA requests
Hi Friends,
I have a requirement where I am loading two different types of data through two different InfoPackages. Both the InfoPackages are scheduled to load data daily to a DataSource. Now the issue is I have to delete data every day from PSA, related to just one InfoPackage before I load data and leave the data coming from other InfoPackage as it is in the PSA.
In other words I want to delete PSA data based on an InfoPackage. I am not sure if we have a standard SAP program to achieve this or it involves custom ABAP code.
Any help will be appreciated.Hi
two info packages are loading data from from same source system or same source system..?
If this 2 info packages are loading from different source systems, then you can achieve this using "Delete PSA" process type.In this process type we can delete PSA based on source system.
If 2 info packages are loading from same source system, then we need to look for ABAP program.
check the below document for ABAP Code
http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/00be6ce4-aa1c-2e10-df81-856c1ffec357?QuickLink=index&overridelayout=true
how to create delete PSA process type in PC
http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/a02ba9e7-bb6f-2c10-09b4-e86b9fcbad41?QuickLink=index&overridelayout=true
Regards,
Venkatesh -
Need towrite ABAP code in cnoverting Country like Malysia to Area like East
Hi ,
Need to write ABAP code in cnoverting Country like Malysia to Area like Ease or West.
Can anybody help me please?
Regards,
krantiHi,
I think you can also do it by concatenating the 2 fields data and displaying it in the result. You can go through the link below which discusses the similar issue. Not very sure which would be the best way to achieve this.
Concatenate 2 fields in a Query
hope this helps in some way.
Regards,
Gaurav -
Hello Experts--
I have query where I will require your expert comments. I would like to check the quality of ABAP code with reference to
(a) Program logic
(b) Performance issues
(c) Table joint
(d) Buffer being used
(e) Index etc etc
Is there any tool in SAP or any third party tool which can help to check the quality of code.
Thanks in advance for your reply.
Regards
--AnshumanDear Anshuman,
Look at the transaction code SCI- Code Inspector and SLIN- Extended program Check - These both together will definitely help you in to a large exten check in your code review and which can help to check you ABAP Code Quality.
There also can be some obsolete statements which need to be take care of and also some SQL queries which are not longer supported in OOPs context.
So hope this will help you to a lot extent in determining the Quality Code.
There are additional Transactions like SE30, ST05 which may help you to know about the performance or time consumption of your programs as such.
Hope this too helps you.
Encourage others to answer you queries by suitably rewarding them
Thanks
Venugopal -
ABAP code to trigger Process Chain (Weekdays)
Dear experts,
I have a process chain which is triggered after an event in BW which is executed after a job in R3 is finished. This job in R3 is executed all days after another event.
I would like this process chain to be executed only from Monday to Friday. What ABAP code should I write in the function module which triggers the BW event in order to execute it only the days I really need to?
Thanks in advance for your help!
Best regards,
CeciliaHello Surendra,
Thakns as well for your help, but my problem is that I don't know any ABAP. With help of SDN posts I've been able to create the program in R3 which calls a FM in BW. My issue now is that I need the exact code which triggers my function module only from Moday to Friday......
The FM I have created in BW which triggers the event is the following (here I suppose I will need a code which says something like, if today is Monday to Friday trigger the event, if not, do not do anything):
FUNCTION Z_BW_EVENT_RAISE_PEDIDOS.
""Interfase local
*" IMPORTING
*" VALUE(EVENTID) LIKE TBTCO-EVENTID
*" EXPORTING
*" VALUE(RESULT) TYPE CHAR2
*" EXCEPTIONS
*" BAD_EVENTID
*" EVENTID_DOES_NOT_EXIST
*" EVENTID_MISSING
*" RAISE_FAILED
*" OTHERS
*data: eventid LIKE TBTCO-EVENTID.
*data: RESULT type CHAR2.
call function 'BP_EVENT_RAISE'
EXPORTING
eventid = eventid
EXCEPTIONS
bad_eventid = 1
eventid_does_not_exist = 2
eventid_missing = 3
raise_failed = 4
others = 5.
if sy-subrc eq 0.
result = 'OK'.
endif.
ENDFUNCTION.
*& Title: Raise Event for BW *
Best regards,
Cecilia -
ABAP performance issues and improvements
Hi All,
Pl. give me the ABAP performance issue and improvement points.
Regards,
HemaPerformance tuning for Data Selection Statement
For all entries
The for all entries creates a where clause, where all the entries in the driver table are combined with OR. If the number of
entries in the driver table is larger than rsdb/max_blocking_factor, several similar SQL statements are executed to limit the
length of the WHERE clause.
The plus
Large amount of data
Mixing processing and reading of data
Fast internal reprocessing of data
Fast
The Minus
Difficult to program/understand
Memory could be critical (use FREE or PACKAGE size)
Some steps that might make FOR ALL ENTRIES more efficient:
Removing duplicates from the the driver table
Sorting the driver table
If possible, convert the data in the driver table to ranges so a BETWEEN statement is used instead of and OR statement:
FOR ALL ENTRIES IN i_tab
WHERE mykey >= i_tab-low and
mykey <= i_tab-high.
Nested selects
The plus:
Small amount of data
Mixing processing and reading of data
Easy to code - and understand
The minus:
Large amount of data
when mixed processing isnt needed
Performance killer no. 1
Select using JOINS
The plus
Very large amount of data
Similar to Nested selects - when the accesses are planned by the programmer
In some cases the fastest
Not so memory critical
The minus
Very difficult to program/understand
Mixing processing and reading of data not possible
Use the selection criteria
SELECT * FROM SBOOK.
CHECK: SBOOK-CARRID = 'LH' AND
SBOOK-CONNID = '0400'.
ENDSELECT.
SELECT * FROM SBOOK
WHERE CARRID = 'LH' AND
CONNID = '0400'.
ENDSELECT.
Use the aggregated functions
C4A = '000'.
SELECT * FROM T100
WHERE SPRSL = 'D' AND
ARBGB = '00'.
CHECK: T100-MSGNR > C4A.
C4A = T100-MSGNR.
ENDSELECT.
SELECT MAX( MSGNR ) FROM T100 INTO C4A
WHERE SPRSL = 'D' AND
ARBGB = '00'.
Select with view
SELECT * FROM DD01L
WHERE DOMNAME LIKE 'CHAR%'
AND AS4LOCAL = 'A'.
SELECT SINGLE * FROM DD01T
WHERE DOMNAME = DD01L-DOMNAME
AND AS4LOCAL = 'A'
AND AS4VERS = DD01L-AS4VERS
AND DDLANGUAGE = SY-LANGU.
ENDSELECT.
SELECT * FROM DD01V
WHERE DOMNAME LIKE 'CHAR%'
AND DDLANGUAGE = SY-LANGU.
ENDSELECT.
Select with index support
SELECT * FROM T100
WHERE ARBGB = '00'
AND MSGNR = '999'.
ENDSELECT.
SELECT * FROM T002.
SELECT * FROM T100
WHERE SPRSL = T002-SPRAS
AND ARBGB = '00'
AND MSGNR = '999'.
ENDSELECT.
ENDSELECT.
Select Into table
REFRESH X006.
SELECT * FROM T006 INTO X006.
APPEND X006.
ENDSELECT
SELECT * FROM T006 INTO TABLE X006.
Select with selection list
SELECT * FROM DD01L
WHERE DOMNAME LIKE 'CHAR%'
AND AS4LOCAL = 'A'.
ENDSELECT
SELECT DOMNAME FROM DD01L
INTO DD01L-DOMNAME
WHERE DOMNAME LIKE 'CHAR%'
AND AS4LOCAL = 'A'.
ENDSELECT
Key access to multiple lines
LOOP AT TAB.
CHECK TAB-K = KVAL.
ENDLOOP.
LOOP AT TAB WHERE K = KVAL.
ENDLOOP.
Copying internal tables
REFRESH TAB_DEST.
LOOP AT TAB_SRC INTO TAB_DEST.
APPEND TAB_DEST.
ENDLOOP.
TAB_DEST[] = TAB_SRC[].
Modifying a set of lines
LOOP AT TAB.
IF TAB-FLAG IS INITIAL.
TAB-FLAG = 'X'.
ENDIF.
MODIFY TAB.
ENDLOOP.
TAB-FLAG = 'X'.
MODIFY TAB TRANSPORTING FLAG
WHERE FLAG IS INITIAL.
Deleting a sequence of lines
DO 101 TIMES.
DELETE TAB_DEST INDEX 450.
ENDDO.
DELETE TAB_DEST FROM 450 TO 550.
Linear search vs. binary
READ TABLE TAB WITH KEY K = 'X'.
READ TABLE TAB WITH KEY K = 'X' BINARY SEARCH.
Comparison of internal tables
DESCRIBE TABLE: TAB1 LINES L1,
TAB2 LINES L2.
IF L1 <> L2.
TAB_DIFFERENT = 'X'.
ELSE.
TAB_DIFFERENT = SPACE.
LOOP AT TAB1.
READ TABLE TAB2 INDEX SY-TABIX.
IF TAB1 <> TAB2.
TAB_DIFFERENT = 'X'. EXIT.
ENDIF.
ENDLOOP.
ENDIF.
IF TAB_DIFFERENT = SPACE.
ENDIF.
IF TAB1[] = TAB2[].
ENDIF.
Modify selected components
LOOP AT TAB.
TAB-DATE = SY-DATUM.
MODIFY TAB.
ENDLOOP.
WA-DATE = SY-DATUM.
LOOP AT TAB.
MODIFY TAB FROM WA TRANSPORTING DATE.
ENDLOOP.
Appending two internal tables
LOOP AT TAB_SRC.
APPEND TAB_SRC TO TAB_DEST.
ENDLOOP
APPEND LINES OF TAB_SRC TO TAB_DEST.
Deleting a set of lines
LOOP AT TAB_DEST WHERE K = KVAL.
DELETE TAB_DEST.
ENDLOOP
DELETE TAB_DEST WHERE K = KVAL.
Tools available in SAP to pin-point a performance problem
The runtime analysis (SE30)
SQL Trace (ST05)
Tips and Tricks tool
The performance database
Optimizing the load of the database
Using table buffering
Using buffered tables improves the performance considerably. Note that in some cases a stament can not be used with a buffered table, so when using these staments the buffer will be bypassed. These staments are:
Select DISTINCT
ORDER BY / GROUP BY / HAVING clause
Any WHERE clasuse that contains a subquery or IS NULL expression
JOIN s
A SELECT... FOR UPDATE
If you wnat to explicitly bypass the bufer, use the BYPASS BUFFER addition to the SELECT clause.
Use the ABAP SORT Clause Instead of ORDER BY
The ORDER BY clause is executed on the database server while the ABAP SORT statement is executed on the application server. The datbase server will usually be the bottleneck, so sometimes it is better to move thje sort from the datsbase server to the application server.
If you are not sorting by the primary key ( E.g. using the ORDER BY PRIMARY key statement) but are sorting by another key, it could be better to use the ABAP SORT stament to sort the data in an internal table. Note however that for very large result sets it might not be a feasible solution and you would want to let the datbase server sort it.
Avoid ther SELECT DISTINCT Statement
As with the ORDER BY clause it could be better to avoid using SELECT DISTINCT, if some of the fields are not part of an index. Instead use ABAP SORT + DELETE ADJACENT DUPLICATES on an internal table, to delete duplciate rows. -
Uncaught Exception occured while sending mail through abap code.
Hi,
Uncaught Exception occured while sending mail through abap code.Run time Errors "UNCAUGHT_EXCEPTION" occured after excuting the call method CALL METHOD SEND_REQUEST->SEND( ).kindly help in resolving the issue.HI,
Runtime Error: UNCAUGHT_EXCEPTION details.
Runtime Errors UNCAUGHT_EXCEPTION
Exception CX_ADDRESS_BCS
Short text
An exception occurred that was not caught.
What happened?
The exception 'CX_ADDRESS_BCS' was raised, but it was not caught anywhere along
the call hierarchy.
Since exceptions represent error situations and this error was not
adequately responded to, the running ABAP program 'SAPLZSEND_MAIL' has to be
terminated.
Error analysis
An exception occurred that is explained in detail below.
The exception, which is assigned to class 'CX_ADDRESS_BCS', was not caught in
procedure "SEND_MAIL" "(FORM)", nor was it propagated by a RAISING clause.
Since the caller of the procedure could not have anticipated that the
exception would occur, the current program is terminated.
The reason for the exception is:
An exception occurred
How to correct the error
If the error occures in a non-modified SAP program, you may be able to
find an interim solution in an SAP Note.
If you have access to SAP Notes, carry out a search with the following
keywords:
"UNCAUGHT_EXCEPTION" "CX_ADDRESS_BCS"
"SAPLZSEND_MAIL" or "LZSEND_MAILU01"
"ZSEND_EMAIL"
If you cannot solve the problem yourself and want to send an error
notification to SAP, include the following information:
1. The description of the current problem (short dump)
To save the description, choose "System->List->Save->Local File
(Unconverted)".
2. Corresponding system log
Display the system log by calling transaction SM21.
Restrict the time interval to 10 minutes before and five minutes
after the short dump. Then choose "System->List->Save->Local File
(Unconverted)".
3. If the problem occurs in a problem of your own or a modified SAP
program: The source code of the program
In the editor, choose "Utilities->More
Utilities->Upload/Download->Download".
4. Details about the conditions under which the error occurred or which
actions and input led to the error.
The exception must either be prevented, caught within proedure
"SEND_MAIL" "(FORM)", or its possible occurrence must be declared in the
RAISING clause of the procedure.
Please help me to resolve this issue.
Maybe you are looking for
-
XML to convert creative html to jsp?
I am trying to find a way to use XML, XSL, etc., to make the process of building web pages at my company easier between the creative team and developers: 1.) The creative team creates the images, text, and html (using Dreamweaver). Please note, the c
-
Hi, when I upload music into itunes from a cd it sometimes appears in itunes as two different albums and split up the music in 2 or even three albums....how can i merge these albums...this is particularly true when one album may have different compos
-
Hi guyes, Pl send me documents on FI-MM, FI-SD & MM-SD integraion Pl fwd it to '[email protected]' Thanks in advance
-
Mu ipad was stolen today and i want to view icloud backup for today. Can i do this?
My ipad was stolen today. It is not showing up on iCloud. Can i view iCloud backup for today? If so how?
-
How can i find out who is under my itunes account?
How do I find out what phones are under my ITunes account?