How to avoid using bapi_commit inside a loop .
Hi ,
Need a help.
This is a program for uploading business partners in CRM.
The basic logic of the program is as below:
- There are two types of records in the upload file new/ old ones to be updated
- A new record is identified by checking if a BP exits based on the cust id
- In case it is a new record certain BAPIs are called to create a new BP, else the address details, identification etc are updated for the existing one.
- SQL analysis of the program showed that the maximum amount of time is taken in INSERT/UPDTAE/COMMIT processes.
When we raised the issue with SAP , they stated that the problem occurs due to the very high no of BAPI_COMMIT calls which is within the loop.
The standard BAPI available allows passing of one record at a time. Hence passing multiple records at a time and a single commit did not seem feasible.
Also while updating since there are different BAPIs for address and identification it is being called in a sequence and commit issued after each. If commit is excluded it gives a locking error since the first BAPI tends to lock the record and does not allow subsequent BAPI call
kindly suggest me with a solution of using a less commit for updating series of records.
The code is as follows:
*& Report ZBP_BDCP_ACCTRNSDATA_UPLOAD *
*& Created By : Radhu Shankar.G *
*& Purpose : Program to Create Investors with the transaction *
*& data received from the De-dupe Software. *
*& Note : Can be Executed or scheduled only in Background *
REPORT zbp_bdcp_acctrnsdata_upload LINE-SIZE 255 LINE-COUNT 65 NO STANDARD PAGE HEADING
MESSAGE-ID zcrm_upload.
TABLES : bbp_iu01.
Selection Screen
SELECTION-SCREEN: BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
PARAMETERS: p_file TYPE string LOWER CASE OBLIGATORY.
SELECTION-SCREEN: END OF BLOCK blk1.
SELECTION-SCREEN: BEGIN OF BLOCK blk2 WITH FRAME TITLE text-002.
SELECT-OPTIONS:s_email FOR bbp_iu01-email NO INTERVALS.
SELECTION-SCREEN: END OF BLOCK blk2.
SELECTION-SCREEN: BEGIN OF BLOCK blk3 WITH FRAME TITLE text-003.
SELECTION-SCREEN COMMENT /1(72) text-004.
SELECTION-SCREEN COMMENT /1(72) text-006.
SELECTION-SCREEN COMMENT /1(72) text-007.
SELECTION-SCREEN COMMENT /1(72) text-005.
SELECTION-SCREEN: END OF BLOCK blk3.
Data Declaration
Main Upload structure and internal table
DATA : BEGIN OF i_main,
cust_id TYPE bu_bpext, " Customer ID
inv_type_code TYPE crmt_mktpfchr_atvalue, " Investor Type Code
insti_tag TYPE crmt_mktpfchr_atvalue, " Retail/Instituitional Tag
name TYPE char120, " Name
address1 TYPE ad_strspp1, " Address1
address2 TYPE ad_strspp2, " Address2
address3 TYPE ad_street, " Address3
city TYPE ad_city1, " City
state TYPE t005u-bezei, " Region/State
country TYPE landx50, " Country
pin_code TYPE ad_pstcd1, " Pin Code
off_phone1 TYPE ad_tlnmbr, " Office Telephone Number1
off_phone2 TYPE ad_tlnmbr, " Office Telephone Number2
res_phone1 TYPE ad_tlnmbr, " Residence Telephone Number1
res_phone2 TYPE ad_tlnmbr, " Residence Telephone Number1
mobile TYPE ad_mbnmbr1, " Mobile Number
email TYPE ad_smtpadr, " Email ID
birth_date TYPE bu_birthdt, " Birth Date
pan_no TYPE bu_id_number, " Pan Number
lob TYPE crmt_mktpfchr_atvalue, " Line of Business
fam_tag TYPE bu_id_number, " FAM Tag Number
mod_date TYPE sy-datum, " Modified Date
END OF i_main.
DATA : it_main LIKE i_main OCCURS 0 WITH HEADER LINE.
Error file structure and internal table
DATA : BEGIN OF i_error,
cust_id TYPE bu_bpext, " Customer ID
inv_type_code TYPE crmt_mktpfchr_atvalue, " Investor Type Code
insti_tag TYPE crmt_mktpfchr_atvalue, " Retail/Instituitional Tag
name TYPE char120, " Name
address1 TYPE ad_strspp1, " Address1
address2 TYPE ad_strspp2, " Address2
address3 TYPE ad_street, " Address3
city TYPE ad_city1, " City
state TYPE t005u-bezei, " Region/State
country TYPE landx50, " Country
pin_code TYPE ad_pstcd1, " Pin Code
off_phone1 TYPE ad_tlnmbr, " Office Telephone Number1
off_phone2 TYPE ad_tlnmbr, " Office Telephone Number2
res_phone1 TYPE ad_tlnmbr, " Residence Telephone Number1
res_phone2 TYPE ad_tlnmbr, " Residence Telephone Number1
mobile TYPE ad_mbnmbr1, " Mobile Number
email TYPE ad_smtpadr, " Email ID
birth_date TYPE bu_birthdt, " Birth Date
pan_no TYPE bu_id_number, " Pan Number
lob TYPE crmt_mktpfchr_atvalue, " Line of Business
fam_tag TYPE bu_id_number, " FAM Tag Number
mod_date TYPE sy-datum, " Modified Date
bp TYPE bapibus1006_head-bpartner, " BP
recno(4) TYPE c, " Record No
message(255) TYPE c, " Error Message
END OF i_error.
DATA : it_error LIKE i_error OCCURS 0 WITH HEADER LINE.
BP Telephone, Email & Role Details
DATA : w_bp_tel TYPE bapiadtel,
it_bp_tel TYPE bapiadtel OCCURS 0 WITH HEADER LINE,
it_bp_tel1 TYPE bapiadtel OCCURS 0 WITH HEADER LINE,
it_bp_email TYPE bapiadsmtp OCCURS 0 WITH HEADER LINE,
it_bp_email1 TYPE bapiadsmtp OCCURS 0 WITH HEADER LINE,
it_bapicomrem TYPE STANDARD TABLE OF bapicomrem WITH HEADER LINE,
it_bapicomrem_x TYPE STANDARD TABLE OF bapicomrex WITH HEADER LINE,
it_tel_x TYPE STANDARD TABLE OF bapiadtelx WITH HEADER LINE,
it_email_x TYPE STANDARD TABLE OF bapiadsmtx WITH HEADER LINE,
it_role TYPE bapibusisb990_bproles OCCURS 0 WITH HEADER LINE,
it_role_cp TYPE bapibusisb990_bproles OCCURS 0 WITH HEADER LINE.
BP Identication Details
DATA: BEGIN OF it_identification OCCURS 0,
idcategory TYPE bapibus1006_identification_key-identificationcategory,
idnumber TYPE bapibus1006_identification_key-identificationnumber,
END OF it_identification.
DATA : w_identification TYPE bapibus1006_identification.
BP Marketing Attributes
DATA : BEGIN OF it_crmt OCCURS 0,
crmt TYPE crmt_mktprof_keys-profile_template_id,
END OF it_crmt.
DATA : it_crmt1 TYPE STANDARD TABLE OF crmt_mktprof_comw WITH HEADER LINE,
it_crmt2 TYPE STANDARD TABLE OF crmt_mktprof_comw WITH HEADER LINE,
it_crmt3 TYPE STANDARD TABLE OF crmt_mktprof_comw WITH HEADER LINE,
it_crmt4 TYPE STANDARD TABLE OF crmt_mktprof_comw WITH HEADER LINE,
it_crmt5 TYPE STANDARD TABLE OF crmt_mktprof_comw WITH HEADER LINE,
it_bp_ret TYPE STANDARD TABLE OF bapiret2 WITH HEADER LINE.
BP Basic Details
DATA : v_partn_cat TYPE bapibus1006_head-partn_cat,
w_central TYPE bapibus1006_central,
w_central_x TYPE bapibus1006_central_x,
w_central_org TYPE bapibus1006_central_organ,
w_central_per TYPE bapibus1006_central_person,
w_central_group TYPE bapibus1006_central_group,
w_centralorg_x TYPE bapibus1006_central_organ_x,
w_centralperson_x TYPE bapibus1006_central_person_x,
w_centralgrp_x TYPE bapibus1006_central_group_x,
w_address TYPE bapibus1006_address,
w_addr_x TYPE bapibus1006_address_x,
v_bp TYPE bapibus1006_head-bpartner.
Declaration for Duplication Check
DATA : w_zacc_address TYPE zacc_address,
g_dup_status TYPE i.
DATA : it_dup_bp TYPE STANDARD TABLE OF zbuspartner WITH HEADER LINE.
CONSTANTS: c_pan TYPE bu_id_type VALUE 'ZID003',
c_fam_tag TYPE bu_id_type VALUE 'ZID011',
c_cust TYPE bu_id_type VALUE 'ZID009'.
Other Declarations
DATA : v_inv_type TYPE crmt_mktpfchr_atvalue, " Investor Type Code
v_file TYPE string,
v_firstname TYPE bu_nameor1,
v_filename1(14) TYPE c,
v_filename2(14) TYPE c,
v_lines TYPE int4,
v_cat TYPE bu_type,
recno TYPE int4,
loopno TYPE int4,
it_iden_ret TYPE bapiret2 OCCURS 0,
it_attr_ret TYPE bapiret2 OCCURS 0,
it_role_ret TYPE bapiret2 OCCURS 0,
wa_iden_ret TYPE bapiret2,
wa_attr_ret TYPE bapiret2,
it_iden_flag TYPE c,
it_attr_flag TYPE c,
flag_central TYPE c,
flag_addr TYPE c,
flag_bp TYPE c,
flag_suc TYPE c,
flag_exist TYPE c,
flag_exit TYPE c,
g_bp_msg TYPE string,
g_bp_msg1 TYPE string.
DATA : BEGIN OF i_success,
rec TYPE int4, "Record
name TYPE bu_nameor1, "Name
bp TYPE bapibus1006_head-bpartner, "Business Partner
END OF i_success,
it_success LIKE i_success OCCURS 0 WITH HEADER LINE,
it_upd_success LIKE i_success OCCURS 0 WITH HEADER LINE.
Data Declaration for converting spool request to PDF and to trigger mail
DATA : gd_recsize TYPE i.
Spool IDs
TYPES : BEGIN OF t_tbtcp.
INCLUDE STRUCTURE tbtcp.
TYPES : END OF t_tbtcp.
DATA : it_tbtcp TYPE STANDARD TABLE OF t_tbtcp INITIAL SIZE 0,
wa_tbtcp TYPE t_tbtcp.
Job Runtime Parameters
DATA : gd_eventid LIKE tbtcm-eventid,
gd_eventparm LIKE tbtcm-eventparm,
gd_external_program_active LIKE tbtcm-xpgactive,
gd_jobcount LIKE tbtcm-jobcount,
gd_jobname LIKE tbtcm-jobname,
gd_stepcount LIKE tbtcm-stepcount,
gd_error TYPE sy-subrc,
gd_reciever TYPE sy-subrc.
DATA : w_recsize TYPE i.
DATA : gd_subject LIKE sodocchgi1-obj_descr,
it_mess_bod LIKE solisti1 OCCURS 0 WITH HEADER LINE,
it_mess_att LIKE solisti1 OCCURS 0 WITH HEADER LINE,
gd_sender_type LIKE soextreci1-adr_typ,
gd_attachment_desc TYPE so_obj_nam,
gd_attachment_name TYPE so_obj_des.
Spool to PDF conversions
DATA : gd_spool_nr LIKE tsp01-rqident,
gd_destination LIKE rlgrap-filename,
gd_bytecount LIKE tst01-dsize,
gd_buffer TYPE string.
Binary store for PDF
DATA : BEGIN OF it_pdf_output OCCURS 0.
INCLUDE STRUCTURE tline.
DATA : END OF it_pdf_output.
DATA : v_email1 TYPE somlreci1-receiver,
v_sender TYPE somlreci1-receiver.
CONSTANTS: c_no(1) TYPE c VALUE ' ',
c_device(4) TYPE c VALUE 'LOCL',
c_delspl TYPE c VALUE 'X'.
DATA : BEGIN OF result OCCURS 0,
line(100) TYPE c,
END OF result.
DATA:i_id_tab TYPE STANDARD TABLE OF bapibus1006_id_details WITH HEADER LINE.
eliminting the error for convt page error
data: g_spl type c value ''.
eliminting the error for convt page error
Initialization
Renaming the target file daily
CONCATENATE '_' sy-datum '.txt' INTO v_filename1.
CONCATENATE '_' sy-datum '.TXT' INTO v_filename2.
START-OF-SELECTION
START-OF-SELECTION.
SELECT COUNT(*) FROM zbp_tax_status.
IF sy-subrc <> 0.
SKIP 2.
WRITE:/ text-011.
STOP.
ENDIF.
REFRESH : it_main.
Uploading the file from either presentatinon layer or application server
PERFORM file_upload.
Creating the BP number and assigning & adding up other attributes
LOOP AT it_main.
PERFORM data_fill. " Filling up global structures & variables
IF v_bp IS INITIAL.
PERFORM duplication_check. " Duplication check
ENDIF.
PERFORM bp_creation. " BP Creation
PERFORM return_fill. " Filling up Return Tables
CLEAR : v_bp, it_main, flag_exit, g_dup_status, it_identification, it_crmt, it_crmt1, it_crmt2, it_crmt3, it_crmt4, it_crmt5,
w_bp_tel,it_bp_tel,it_bp_tel1,it_bp_email,it_bp_email1,it_tel_x,it_email_x,w_addr_x,w_centralorg_x,w_centralperson_x,
w_centralgrp_x,flag_addr,flag_central,it_iden_flag,it_attr_flag,it_bapicomrem,w_central,w_central_x, v_inv_type,it_bapicomrem_x,
w_central_org,w_central_per,w_central_group,flag_bp,flag_suc,flag_exist,it_bp_ret,g_bp_msg,g_bp_msg1,v_cat,wa_attr_ret.
REFRESH :it_identification, it_crmt, it_crmt1, it_crmt2, it_crmt3, it_crmt4, it_crmt5,it_bapicomrem,
it_bp_tel,it_bp_tel1,it_bp_email,it_bp_email1,it_tel_x,it_email_x,it_bp_ret,it_bapicomrem_x.
ENDLOOP.
Downloading the file to be reprocessed to the application server
IF it_error[] IS NOT INITIAL.
PERFORM error_file_download.
ENDIF.
Constructing the Return Messages for the Job
PERFORM return_messages. " Return Message Construction
Converting the return messages into PDF file and trigerring a mail notification
IF sy-batch EQ 'X'.
PERFORM get_job_details.
PERFORM obtain_spool_id.
PERFORM convert_spool_to_pdf.
PERFORM process_email.
PERFORM trigger_email.
ENDIF.
*& Form file_upload
FORM file_upload .
Data declatration
DATA: l_filestr TYPE string.
CLASS cl_abap_char_utilities DEFINITION LOAD.
CONSTANTS: con_tab TYPE c VALUE cl_abap_char_utilities=>horizontal_tab.
REPLACE '.txt' WITH v_filename1 INTO p_file .
REPLACE '.TXT' WITH v_filename2 INTO p_file .
MOVE p_file TO v_file.
IF sy-batch EQ 'X'.
Uploading the file from application server if the job is scheduled in background
OPEN DATASET p_file FOR INPUT IN TEXT MODE ENCODING DEFAULT
eliminting the error for convt page error
IGNORING CONVERSION ERRORS REPLACEMENT CHARACTER g_spl.
eliminting the error for convt page error
IF sy-subrc = 0.
DO.
READ DATASET p_file INTO l_filestr.
IF sy-subrc <> 0.
EXIT.
ELSE.
CLEAR it_main.
SPLIT l_filestr AT con_tab INTO:
it_main-cust_id it_main-inv_type_code
it_main-insti_tag it_main-name
it_main-address1 it_main-address2
it_main-address3 it_main-city
it_main-state it_main-country
it_main-pin_code it_main-off_phone1
it_main-off_phone2 it_main-res_phone1
it_main-res_phone2 it_main-mobile
it_main-email it_main-birth_date
it_main-pan_no it_main-lob
it_main-fam_tag it_main-mod_date.
APPEND it_main.
ENDIF.
ENDDO.
ELSE.
WRITE : / 'The file',
p_file,
'is not found.'.
STOP.
ENDIF.
CLOSE DATASET p_file.
ELSE.
WRITE : / 'The Program can only be executed in the background.'.
STOP.
ENDIF.
CLEAR : l_filestr, it_main.
ENDFORM. " file_upload
*& Form data_fill
FORM data_fill .
Filling up Partner Category (v_Partn_cat) ,workarea (w_central), workarea (w_central_org) & workarea (w_central_per)
SELECT SINGLE bp_category tax_status FROM zbp_tax_status
INTO (v_partn_cat,v_inv_type)
WHERE inv_code EQ it_main-inv_type_code.
Filling up the Authorization Group
IF it_main-lob EQ 'M' AND it_main-insti_tag EQ 'N'.
w_central-authorizationgroup = 'ZMFR'.
ELSEIF it_main-lob EQ 'M' AND it_main-insti_tag EQ 'Y'.
w_central-authorizationgroup = 'ZMFI'.
ELSEIF it_main-lob EQ 'P' AND it_main-insti_tag EQ 'N'.
w_central-authorizationgroup = 'ZPMR'.
ELSEIF it_main-lob EQ 'P' AND it_main-insti_tag EQ 'Y'.
w_central-authorizationgroup = 'ZPMI'.
ELSEIF it_main-lob EQ 'A' AND it_main-insti_tag EQ 'N'.
w_central-authorizationgroup = 'ZBOR'.
ELSEIF it_main-lob EQ 'A' AND it_main-insti_tag EQ 'Y'.
w_central-authorizationgroup = 'ZBOI'.
ENDIF.
Filling up workarea (w_address)
IF it_main-address1 IS NOT INITIAL.
MOVE : it_main-address1 TO w_address-str_suppl1,
it_main-address1 TO w_zacc_address-address1,
'X' TO w_addr_x-str_suppl1 .
ENDIF.
IF it_main-address2 IS NOT INITIAL.
MOVE : it_main-address2 TO w_address-str_suppl2,
it_main-address2 TO w_zacc_address-address2,
'X' TO w_addr_x-str_suppl2 .
ENDIF.
IF it_main-address3 IS NOT INITIAL.
MOVE : it_main-address3 TO w_address-street,
it_main-address3 TO w_zacc_address-address3,
'X' TO w_addr_x-street.
ENDIF.
IF it_main-city IS NOT INITIAL.
MOVE : it_main-city TO w_address-city,
it_main-city TO w_zacc_address-city,
'X' TO w_addr_x-city.
ENDIF.
IF it_main-pin_code IS NOT INITIAL.
MOVE : it_main-pin_code TO w_address-postl_cod1,
'X' TO w_addr_x-postl_cod1.
TRANSLATE w_address-postl_cod1 TO UPPER CASE.
ENDIF.
IF it_main-country IS NOT INITIAL.
MOVE : 'X' TO w_addr_x-country.
ENDIF.
IF it_main-state IS NOT INITIAL.
MOVE: 'X' TO w_addr_x-region.
ENDIF.
Picking up Country & State Codes
SELECT SINGLE land1 FROM t005t INTO w_address-country
WHERE spras EQ 'E'
AND landx50 EQ it_main-country.
IF sy-subrc EQ 0.
SELECT SINGLE bland FROM t005u INTO w_address-region
WHERE spras EQ 'E'
AND land1 EQ w_address-country
AND bezei EQ it_main-state.
IF sy-subrc NE 0.
w_address-region = 'ZZ'.
ENDIF.
ELSE.
w_address-country = 'ZZ'.
SELECT SINGLE bland FROM t005u INTO w_address-region
WHERE spras EQ 'E'
AND land1 EQ w_address-country
AND bezei EQ it_main-state.
IF sy-subrc NE 0.
w_address-region = 'ZZ'.
ENDIF.
ENDIF.
w_zacc_address-country = w_address-country.
w_zacc_address-state = w_address-region.
Filling up the BP Role Detail
it_role-partnerrole = 'Z1INVS'.
APPEND it_role.
Finding out the BP number from the client ID
IF it_main-cust_id IS NOT INITIAL.
SELECT SINGLE partner FROM but0id INTO v_bp
WHERE type EQ 'ZID009'
AND idnumber EQ it_main-cust_id.
IF sy-subrc = 0.
SELECT SINGLE type FROM but000 INTO v_cat
WHERE partner = v_bp.
PERFORM name_processing USING v_cat.
ENDIF.
ENDIF.
IF v_bp IS INITIAL.
PERFORM name_processing USING v_partn_cat. " Processing the Name & Title depending on partner category
Filling up the Identication Number Details
IF it_main-cust_id IS NOT INITIAL. " Customer ID
it_identification-idcategory = 'ZID009'.
it_identification-idnumber = it_main-cust_id.
APPEND it_identification.
CLEAR it_identification.
ENDIF.
IF it_main-pan_no IS NOT INITIAL. " Pan Number
it_identification-idcategory = 'ZID003'.
it_identification-idnumber = it_main-pan_no.
APPEND it_identification.
CLEAR it_identification.
ENDIF.
IF it_main-fam_tag IS NOT INITIAL. " Family Tag Number
it_identification-idcategory = 'ZID011'.
it_identification-idnumber = it_main-fam_tag.
APPEND it_identification.
CLEAR it_identification.
ENDIF.
Filling up the Marketing Attributes
IF v_inv_type IS NOT INITIAL. " Tax status
it_crmt1-atname = 'TAX_STATUS'.
it_crmt1-atwrt = v_inv_type.
APPEND it_crmt1.
CLEAR : it_crmt1.
ENDIF.
IF it_main-lob IS NOT INITIAL. " Product Tag
it_crmt1-atname = 'LOB'.
IF it_main-lob EQ 'M'.
it_crmt1-atwrt = 'MF'.
ELSEIF it_main-lob EQ 'P'.
it_crmt1-atwrt = 'PMS'.
ELSEIF it_main-lob EQ 'A'.
it_crmt1-atwrt = 'BOTH'.
ENDIF.
APPEND it_crmt1.
CLEAR : it_crmt1.
ENDIF.
IF it_main-insti_tag IS NOT INITIAL. " Retail/Instituitional Tag
it_crmt1-atname = 'ORGANISATION_STRUCTURE'.
IF it_main-insti_tag EQ 'N'.
it_crmt1-atwrt = 'RETAIL'.
ELSEIF it_main-insti_tag EQ 'Y'.
it_crmt1-atwrt = 'INSTITUTIONAL'.
ELSEIF it_main-insti_tag EQ 'F'.
it_crmt1-atwrt = 'INTERNATIONAL'.
ENDIF.
APPEND it_crmt1.
CLEAR : it_crmt1.
ENDIF.
it_crmt2-atname = 'VIP'.
it_crmt2-atwrt = 'NOT CLASSIFIED'.
APPEND it_crmt2.
CLEAR : it_crmt2.
it_crmt3-atname = 'PRIORITY'.
it_crmt3-atwrt = 'NOT CLASSIFIED'.
APPEND it_crmt3.
CLEAR : it_crmt3.
it_crmt4-atname = 'CONTACTBLE'.
it_crmt4-atwrt = 'NOT CLASSIFIED'.
APPEND it_crmt4.
CLEAR : it_crmt4.
it_crmt5-atname = 'SOURCE'.
it_crmt5-atwrt = 'CAMS'.
APPEND it_crmt5.
CLEAR : it_crmt5.
it_crmt-crmt = 'CENTALISED_CLF_INV'.
APPEND it_crmt.
it_crmt-crmt = 'GENERAL_CLF_INV'.
APPEND it_crmt.
it_crmt-crmt = 'MF_CLF_INV'.
APPEND it_crmt.
it_crmt-crmt = 'PMS_CLF_INV'.
APPEND it_crmt.
it_crmt-crmt = 'SOURCE'.
APPEND it_crmt.
CLEAR it_crmt-crmt.
ENDIF.
For Return Message
recno = recno + 1.
ENDFORM. " data_fill
*& Form duplication_check
FORM duplication_check .
DATA : l_lines TYPE i.
IF v_firstname IS NOT INITIAL.
CALL FUNCTION 'ZACC_DUPLICATIONCHECK'
EXPORTING
role = 'Z1INVS'
firstname = v_firstname
pan_no = it_main-pan_no
mobile = it_main-mobile
email = it_main-email
address = w_zacc_address
partnercategory = v_partn_cat
IMPORTING
status = g_dup_status
TABLES
buspartner = it_dup_bp.
DESCRIBE TABLE it_dup_bp LINES l_lines.
IF l_lines EQ 1.
IF g_dup_status EQ 1.
READ TABLE it_dup_bp INDEX 1.
MOVE it_dup_bp-partner TO v_bp.
ELSEIF g_dup_status EQ 2.
flag_exit = 'X'.
ENDIF.
ELSEIF l_lines GT 1.
flag_exit = 'X'.
ENDIF.
ENDIF.
CLEAR : l_lines, v_firstname.
ENDFORM. " duplication_check
*& Form name_processing
FORM name_processing USING uv_cat TYPE bu_type.
IF it_main-name IS NOT INITIAL.
If category is Person
IF uv_cat EQ 1.
CALL FUNCTION 'ZGET_NAME_FROM_STRING'
EXPORTING
name = it_main-name
IMPORTING
first = w_central_per-firstname
middle = w_central_per-middlename
last = w_central_per-lastname.
w_centralperson_x-firstname = 'X'.
w_centralperson_x-middlename = 'X'.
w_centralperson_x-lastname = 'X'.
w_centralperson_x-birthdate = 'X'.
MOVE : it_main-birth_date TO w_central_per-birthdate,
w_central_per-firstname TO v_firstname.
ELSEIF uv_cat EQ 2.
If category is organisation
CALL FUNCTION 'ZGET_NAME_FROM_STRING'
EXPORTING
name = it_main-name
IMPORTING
first = w_central_org-name2
middle = w_central_org-name1
last = w_central_org-name3.
w_centralorg_x-name1 = 'X'.
w_centralorg_x-name2 = 'X'.
w_centralorg_x-name3 = 'X'.
MOVE w_central_org-name2 TO v_firstname.
ELSEIF uv_cat EQ 3.
If category is group
CALL FUNCTION 'ZGET_NAME_FROM_STRING'
EXPORTING
name = it_main-name
IMPORTING
first = w_central_group-namegroup2
middle = w_central_group-namegroup1.
w_centralgrp_x-namegroup1 = 'X'.
w_centralgrp_x-namegroup2 = 'X'.
MOVE w_central_group-namegroup2 TO v_firstname.
ENDIF.
MOVE : it_main-name+0(8) TO w_central-searchterm1,
'X' TO w_central_x-searchterm1.
ENDIF.
ENDFORM. " name_processing
*& Form bp_creation
FORM bp_creation.
DATA:l_identification TYPE bapibus1006_identification_key-identificationnumber.
BP Creation
IF v_bp IS INITIAL.
Filling up the Telephone Details
MOVE : w_address-country TO w_bp_tel-country.
IF it_main-off_phone1 IS NOT INITIAL. " Office Telephone1
w_bp_tel-r_3_user = '1'.
w_bp_tel-telephone = it_main-off_phone1.
APPEND w_bp_tel TO it_bp_tel.
CLEAR : w_bp_tel-r_3_user, w_bp_tel-telephone.
it_bapicomrem-comm_type = 'TEL'.
it_bapicomrem-langu = 'EN'.
it_bapicomrem-comm_notes = 'OFFICE PHONE1'.
APPEND it_bapicomrem.
ENDIF.
IF it_main-off_phone2 IS NOT INITIAL. " Office Telephone2
w_bp_tel-telephone = it_main-off_phone2.
APPEND w_bp_tel TO it_bp_tel.
CLEAR : w_bp_tel-telephone.
it_bapicomrem-comm_type = 'TEL'.
it_bapicomrem-langu = 'EN'.
it_bapicomrem-comm_notes = 'OFFICE PHONE2'.
APPEND it_bapicomrem.
ENDIF.
IF it_main-res_phone1 IS NOT INITIAL. " Residence Telephone1
w_bp_tel-telephone = it_main-res_phone1.
APPEND w_bp_tel TO it_bp_tel.
CLEAR : w_bp_tel-telephone.
it_bapicomrem-comm_type = 'TEL'.
it_bapicomrem-langu = 'EN'.
it_bapicomrem-comm_notes = 'RESIDENCE PHONE1'.
APPEND it_bapicomrem.
ENDIF.
IF it_main-res_phone2 IS NOT INITIAL. " Residence Telephone2
w_bp_tel-telephone = it_main-res_phone2.
APPEND w_bp_tel TO it_bp_tel.
CLEAR : w_bp_tel-telephone.
it_bapicomrem-comm_type = 'TEL'.
it_bapicomrem-langu = 'EN'.
it_bapicomrem-comm_notes = 'RESIDENCE PHONE2'.
APPEND it_bapicomrem.
ENDIF.
IF it_main-mobile IS NOT INITIAL. " Mobile Number
w_bp_tel-r_3_user = '3'.
w_bp_tel-telephone = it_main-mobile.
APPEND w_bp_tel TO it_bp_tel.
CLEAR : w_bp_tel-r_3_user, w_bp_tel-telephone.
ENDIF.
Filling up the E-Mail Details
IF it_main-email IS NOT INITIAL. " E-mail1
it_bp_email-e_mail = it_main-email.
APPEND it_bp_email.
CLEAR it_bp_email.
ENDIF.
BAPI for BP creation
CALL FUNCTION 'BAPI_BUPA_FS_CREATE_FROM_DATA2'
EXPORTING
partnercategory = v_partn_cat
centraldata = w_central
centraldataperson = w_central_per
centraldataorganization = w_central_org
centraldatagroup = w_central_group
addressdata = w_address
IMPORTING
businesspartner = v_bp
TABLES
telefondata = it_bp_tel
communicationnotes = it_bapicomrem
e_maildata = it_bp_email
roles = it_role
return = it_bp_ret.
IF v_bp IS NOT INITIAL.
flag_bp = 'X'.
ENDIF.
Commiting the transaction
PERFORM transaction_commit.
To add Identification details to BP
PERFORM add_details.
CLEAR : v_partn_cat, w_central, w_central_per, w_central_org, it_bp_tel, it_bp_email, it_role.
REFRESH : it_bp_tel, it_bp_email, it_role.
ELSE.
flag_exist = 'X'.
If BP exists,address,communication and ID details will be updated
CALL FUNCTION 'BAPI_BUPA_CENTRAL_CHANGE'
EXPORTING
businesspartner = v_bp
centraldata = w_central
centraldataperson = w_central_per
centraldataorganization = w_central_org
centraldatagroup = w_central_group
centraldata_x = w_central_x
centraldataperson_x = w_centralperson_x
centraldataorganization_x = w_centralorg_x
centraldatagroup_x = w_centralgrp_x
TABLES
return = it_bp_ret.
READ TABLE it_bp_ret WITH KEY type = 'E'.
IF sy-subrc = 0.
flag_central = 'E'.
g_bp_msg = it_bp_ret-message.
CLEAR:it_bp_ret.
REFRESH:it_bp_ret.
ELSE.
flag_suc = 'X'.
ENDIF.
PERFORM transaction_commit.
To get the existing communication details
CALL FUNCTION 'BAPI_BUPA_ADDRESS_GETDETAIL'
EXPORTING
businesspartner = v_bp
TABLES
bapiadtel = it_bp_tel1
bapiadsmtp = it_bp_email1.
LOOP AT it_bp_tel1 WHERE r_3_user = '1' OR r_3_user = ' '.
it_bp_tel-consnumber = it_bp_tel1-consnumber.
it_tel_x-updateflag = 'D'.
APPEND:it_bp_tel,
it_tel_x.
CLEAR: it_bp_tel,
it_tel_x.
ENDLOOP.
IF it_main-mobile IS NOT INITIAL .
LOOP AT it_bp_tel1 WHERE r_3_user = '2' OR r_3_user = '3'.
it_bp_tel-consnumber = it_bp_tel1-consnumber.
it_tel_x-updateflag = 'D'.
APPEND:it_bp_tel,
it_tel_x.
CLEAR: it_bp_tel,
it_tel_x.
ENDLOOP.
ENDIF.
*Updating communication details
IF it_main-off_phone1 IS NOT INITIAL. " Office Telephone1
w_bp_tel-r_3_user = '1'.
w_bp_tel-telephone = it_main-off_phone1.
it_tel_x-telephone = 'I'.
it_tel_x-updateflag = 'I'.
APPEND:it_tel_x.
CLEAR: it_tel_x.
APPEND w_bp_tel TO it_bp_tel.
CLEAR : w_bp_tel-r_3_user, w_bp_tel-telephone.
it_bapicomrem-comm_type = 'TEL'.
it_bapicomrem-langu = 'EN'.
it_bapicomrem-comm_notes = 'OFFICE PHONE1'.
APPEND it_bapicomrem.
it_bapicomrem_x-comm_type = 'I'.
it_bapicomrem_x-langu = 'I'.
it_bapicomrem_x-comm_notes = 'I'.
it_bapicomrem_x-updateflag = 'I'.
APPEND it_bapicomrem_x.
ENDIF.
IF it_main-off_phone2 IS NOT INITIAL. " Office Telephone2
w_bp_tel-telephone = it_main-off_phone2.
APPEND w_bp_tel TO it_bp_tel.
it_tel_x-telephone = 'I'.
it_tel_x-updateflag = 'I'.
APPEND:it_tel_x.
CLEAR:it_tel_x.
CLEAR : w_bp_tel-telephone.
it_bapicomrem-comm_type = 'TEL'.
it_bapicomrem-langu = 'EN'.
it_bapicomrem-comm_notes = 'OFFICE PHONE2'.
APPEND it_bapicomrem.
it_bapicomrem_x-comm_type = 'I'.
it_bapicomrem_x-langu = 'I'.
it_bapicomrem_x-comm_notes = 'I'.
it_bapicomrem_x-updateflag = 'I'.
APPEND it_bapicomrem_x.
ENDIF.
IF it_main-res_phone1 IS NOT INITIAL. " Residence Telephone1
w_bp_tel-telephone = it_main-res_phone1.
APPEND w_bp_tel TO it_bp_tel.
it_tel_x-telephone = 'I'.
it_tel_x-updateflag = 'I'.
APPEND:it_tel_x.
CLEAR:it_tel_x.
CLEAR : w_bp_tel-telephone.
it_bapicomrem-comm_type = 'TEL'.
it_bapicomrem-langu = 'EN'.
it_bapicomrem-comm_notes = 'RESIDECE PHONE1'.
APPEND it_bapicomrem.
it_bapicomrem_x-comm_type = 'I'.
it_bapicomrem_x-langu = 'I'.
it_bapicomrem_x-comm_notes = 'I'.
it_bapicomrem_x-updateflag = 'I'.
APPEND it_bapicomrem_x.
ENDIF.
IF it_main-res_phone2 IS NOT INITIAL. " Residence Telephone2
w_bp_tel-telephone = it_main-res_phone2.
APPEND w_bp_tel TO it_bp_tel.
it_tel_x-telephone = 'I'.
it_tel_x-updateflag = 'I'.
APPEND:it_tel_x.
CLEAR:it_tel_x.
CLEAR : w_bp_tel-telephone.
it_bapicomrem-comm_type = 'TEL'.
it_bapicomrem-langu = 'EN'.
it_bapicomrem-comm_notes = 'RESIDECE PHONE2'.
APPEND it_bapicomrem.
it_bapicomrem_x-comm_type = 'I'.
it_bapicomrem_x-langu = 'I'.
it_bapicomrem_x-comm_notes = 'I'.
it_bapicomrem_x-updateflag = 'I'.
APPEND it_bapicomrem_x.
ENDIF.
IF it_main-mobile IS NOT INITIAL. " Mobile Number
w_bp_tel-r_3_user = '3'.
w_bp_tel-telephone = it_main-mobile.
APPEND w_bp_tel TO it_bp_tel.
it_tel_x-telephone = 'I'.
it_tel_x-updateflag = 'I'.
APPEND:it_tel_x.
CLEAR:it_tel_x.
CLEAR : w_bp_tel-r_3_user, w_bp_tel-telephone.
ENDIF.
IF it_main-email IS NOT INITIAL.
LOOP AT it_bp_email1.
it_bp_email-consnumber = it_bp_email1-consnumber.
it_email_x-updateflag = 'D'.
APPEND:it_bp_email,
it_email_x.
ENDLOOP.
it_bp_email-e_mail = it_main-email.
it_email_x-e_mail = 'I'.
it_email_x-updateflag = 'I'.
APPEND:it_bp_email,
it_email_x.
CLEAR:it_bp_email,
it_email_x.
ENDIF.
REFRESH:it_bp_ret.
BP Change
CALL FUNCTION 'BAPI_BUPA_ADDRESS_CHANGE'
EXPORTING
businesspartner = v_bp
addressdata = w_address
addressdata_x = w_addr_x
TABLES
bapiadtel = it_bp_tel
bapicomrem = it_bapicomrem
bapiadtel_x = it_tel_x
bapiadsmtp = it_bp_email
bapiadsmt_x = it_email_x
bapicomre_x = it_bapicomrem_x
return = it_bp_ret.
READ TABLE it_bp_ret WITH KEY type = 'E'.
IF sy-subrc = 0.
flag_addr = 'E'.
g_bp_msg1 = it_bp_ret-message.
ELSE.
flag_suc = 'X'.
ENDIF.
PERFORM transaction_commit.
REFRESH it_bp_ret.
IF it_main-pan_no IS NOT INITIAL OR it_main-fam_tag IS NOT INITIAL OR it_main-cust_id IS NOT INITIAL.
Retreiving the existing Identification details
PERFORM id_get USING v_bp.
ENDIF.
PAN number addition
IF it_main-pan_no IS NOT INITIAL.
CLEAR l_identification.
MOVE it_main-pan_no TO l_identification.
TRANSLATE l_identification TO UPPER CASE.
READ TABLE i_id_tab WITH KEY identificationtype = c_pan.
IF sy-subrc = 0.
To remove existing PAN number
PERFORM id_remove USING v_bp c_pan i_id_tab-identificationnumber.
READ TABLE it_iden_ret INTO wa_iden_ret WITH KEY type = 'E'.
IF sy-subrc EQ 0.
it_iden_flag = 'E'.
ELSE.
flag_suc = 'X'.
Performing transaction commit
PERFORM transaction_commit.
ENDIF.
ENDIF.
CLEAR:it_iden_ret[],it_iden_ret.
To add new PAN number
PERFORM id_add USING v_bp c_pan l_identification.
READ TABLE it_iden_ret INTO wa_iden_ret WITH KEY type = 'E'.
IF sy-subrc EQ 0.
it_iden_flag = 'E'.
ELSE.
flag_suc = 'X'.
PERFORM transaction_commit.
ENDIF.
ENDIF.
Customer ID addition
IF it_main-cust_id IS NOT INITIAL AND ( g_dup_status = 1 ).
CLEAR l_identification.
MOVE it_main-cust_id TO l_identification.
TRANSLATE l_identification TO UPPER CASE.
READ TABLE i_id_tab WITH KEY identificationtype = c_cust.
IF sy-subrc = 0.
To remove existing Customer ID
PERFORM id_remove USING v_bp c_cust i_id_tab-identificationnumber.
READ TABLE it_iden_ret INTO wa_iden_ret WITH KEY type = 'E'.
IF sy-subrc EQ 0.
it_iden_flag = 'E'.
ELSE.
Performing transaction commit
PERFORM transaction_commit.
ENDIF.
ENDIF.
CLEAR:it_iden_ret[],it_iden_ret.
To add new Customer ID number
PERFORM id_add USING v_bp c_cust l_identification.
READ TABLE it_iden_ret INTO wa_iden_ret WITH KEY type = 'E'.
IF sy-subrc EQ 0.
it_iden_flag = 'E'.
ELSE.
flag_suc ='X'.
PERFORM transaction_commit.
ENDIF.
ENDIF.
To add marketing attributes
IF it_main-insti_tag IS NOT INITIAL AND it_main-lob IS NOT INITIAL.
PERFORM add_makt_attr .
ELSE.
it_attr_flag = 'E'.
Guy,i don't regard here is anybody wanna read so much code .For more constructive answers, you would distill core question from your program.
Similar Messages
-
How to avoid data selection inside the loop?
Hello Experts,
I am working on one performance item and I have already applied some changes to the original version.
Now, If I compare my new program with old program, I have good improvement in performance. I am checking if I can do anything on statements that are top on the below list. I think 40% for Modify statement is acceptable after my research (Below run is updating around 20M records which is real time volume for this application).
As we can see 34% of run time to going for one SELECT query on custom table. Take a look at below high level flow of my program to understand above select query.
1. Select data from ZABC
2. Select data from Variant Table (Var1, Var2, Var3 etc.., 12 in real time)
3. Loop Variant Table
4. Select data from X, Y, Z table for Var<n>.
5. Populate final internal table from ZABC, X, Y and Z table
6. Modify ZTABLE with Final Internal table data
7. End Loop on Variant Table
As described in the flow of the program, ZABC table data is common for all the variants and need not to fetch multiple times. Hence I am doing it only once in my program. Below is that select query:
select rrcty ryear rbukrs racct rcntr sum( amt1) as amt1 "Like I have 32 amount fields in original query
from zabc
into table i_zabc
where ryear in r_year " Two records in ranges with I and EQ
and rvers = '001'
and rrcty in r_rrcty "Three records in ranges with I and EQ
and rldnr = 'DT'
group by rrcty ryear rbukrs racct rcntr
order by rrcty ryear rbukrs racct rcntr.
ZABC table is again having huge volume of data and we are fetching millions of records with above query. That is primary reason to take long time. May be that is okay as I am already using Indexes of this table. But, I am not comfortable with it as it can reach max. memory point and through run time error. Fetch Cursor is one reliable option that I can see here, but with that, I should move ZABC selection inside the variant loop which can cause fetching ZABC data 12 times (Let me know If I am missing anything here).
Now, third statement in my trace results, with 10% of overall time is this:
loop at i_abc assigning <fs_abc>.
loop at i_table assigning <fs_table> where low <= <fs_abc>-racct and high >= <fs_abc>-racct.
endloop.
endloop.
6 million executions with this complex WHERE condition is causing this statement to get 3rd position in trace results. I tried below two options which are, I think, taking even more time - (I am still monitoring these options)
1) Removed WHERE condition on LOW, HIGH and applied filter inside the loop.
2) Removed WHERE condition on HIGH only and applied filter inside the loop.
Any suggestions on how to proceed with ZABC selection and I_TABLE loop.
Let me know if you have any questions on above compose.Since I looked at this case before, let me try some quick suggestions:
Is table ZABC related to table X, Y and/or Z and can the selection be limited by applying those 12 selection variants?
If yes, try a join select involving these tables that could make your step 1 obsolete and replace steps 4 and 5.
This might also get rid of the "loop inside loop" problem. Generally, make sure that the inner table is declared as a sorted table with a key that consists of the fields as used in the WHERE-condition of the inner loop. Use secondary keys for internal tables if your ABAP release permits and the task at hand warrants it.
Finally, look at PACKAGE SIZE option for the (join) select to reduce memory consumption.
Thomas -
Do you know how i can use Ipad inside ATEX certified areas ( e.g. refinery plant) ? Do you know if exist somespecial arrangement ( cover, enclosure, ecc) for this ?
Hello
At least one cover manufactrer will try to propose an Atex (Ex 2) cover for ipad
http://dofero.com/Viz-iCARRY.html
i dont know if it is already on the market.
Another one is making IP68 and military Standard 810F-516.15 that seems to include some kind of ability to work in explosible atmosphere.
http://www.lifeproof.com/ipad#why-nuud
Here what I found. I'm also interested of further talk on this topic, workimg as Occupational Hygienist for Swiss Industries.
hope this post helps.
Best Regards
Vincent -
How can i use JSTL inside custom tag attribute
Hi,
I have one button tag which displays the button with round corner. I will show the button like this:
<ep:button key="buttons.submit" name="submitBtn" styleClass="But"
onClick='submitPage(''<c:out value='${buttonName}' />)' />
I am getting the problem with the above code. how can i use JSTL inside the custom tags.
Thanks in Advance,
LALITHNo. The details are given below:
I have included the follwing line in web.xml file:
<taglib>
<taglib-uri>/tags/button</taglib-uri>
<taglib-location>/WEB-INF/button.tld</taglib-location>
</taglib>button.tld file
<taglib>
<tlibversion>1.0</tlibversion>
<jspversion>2.0</jspversion>
<shortname>button</shortname>
<tag>
<name>button</name>
<tagclass>com.ksi.ep.web.taglib.ButtonTag</tagclass>
<bodycontent>empty</bodycontent>
<attribute>
<name>name</name>
<required>true</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
<attribute>
<name>key</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>onClick</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</taglib>ButtonTag.java :
public class ButtonTag extends TagSupport {
private static final long serialVersionUID = 6837146537426981407L;
* Initialise the logger for the class
protected final transient Log log = LogFactory.getLog(ButtonTag.class);
* holds the Value of the button tag
protected String onClick = null;
* holds message resources key
protected String key = null;
* The message resources for this package.
protected static MessageResources messages =
MessageResources.getMessageResources
("ApplicationResources");
* (non-Javadoc)
* @see javax.servlet.jsp.tagext.TagSupport#doStartTag()
public int doStartTag() throws JspException {
StringBuffer label = new StringBuffer();
HttpServletRequest request = (HttpServletRequest)pageContext.getRequest();
try {
log.debug("in doStartTag()");
Locale locale = pageContext.getRequest().getLocale();
if (locale == null) {
locale = Locale.getDefault();
log.info("");
label.append("<a border=\"0\" style=\"text-decoration:none;color:#FFFFFF\" href=\"JavaScript:");
label.append(onClick);
label.append("\" >");
label.append("<table onClick=\"");
label.append(onClick);
label.append("\" ");
if(onmouseout!=null && !"".equalsIgnoreCase(onmouseout))
label.append(" onmouseout=\"");
label.append(onmouseout);
label.append("\" ");
if(onmouseover!=null && !"".equalsIgnoreCase(onmouseover)){
label.append(" onmouseover=\"");
label.append(onmouseover);
label.append("\" ");
if(title!=null && !"".equalsIgnoreCase(title)){
label.append(" title=\"");
label.append(title);
label.append("\" ");
label.append("style=\"cursor:hand\" tabindex=\"1\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" background=\"");
label.append(request.getContextPath());
label.append(System.getProperty("file.separator"));
label.append("images");
label.append(System.getProperty("file.separator"));
label.append("background1.jpg\" > ");
label.append("<tr><td width=\"10\"><img border=\"0\" src=\"");
label.append(request.getContextPath());
label.append(System.getProperty("file.separator"));
label.append("images");
label.append(System.getProperty("file.separator"));
label.append("leftcorner.jpg\" ></td> ");
label.append("<td valign=\"middle\" style=\"padding-bottom:2px\"><font color=\"#FFFFFF\" style=\"");
label.append(styleClass);
label.append("\">");
label.append(messages.getMessage(key));
label.append("</font></td>");
label.append("<td width=\"10\" align=\"right\"><img src=\"");
label.append(request.getContextPath());
label.append(System.getProperty("file.separator"));
label.append("images");
label.append(System.getProperty("file.separator"));
label.append("rightcorner.jpg\" border=\"0\" ></td>");
label.append("</tr></table></a>");
pageContext.getOut().print(label.toString());
} catch (Exception e) {
log.error("Exception occured while rendering the button", e);
throw new JspException(e);
return (SKIP_BODY);
* Release all allocated resources.
public void release() {
this.name=null;
this.key=null;
this.onClick=null;
}In my JSP I have mentioned the taglib directive as
<%@ taglib uri="/tags/button" prefix="ep"%>and
<ep:button key="buttons.submit" name="submitBtn" styleClass="But"
onClick='overwritePreApprovals('<c:out value='${transactionalDetails['inPrepList']}' />')' />Servlet.service() for servlet action threw exception
org.apache.jasper.JasperException: /pages/pms/coordinator/Dashboard.jsp(325,48) Unterminated <ep:button tag
Thanks,
LALITH -
How to avoid select with in a loop.
Hi friends,
can any tell how to avoid the select with in a loop for the following code, since it badly effecting my performance. if possible with code
SELECT matnr werks
FROM marc
INTO TABLE it_marc
FOR ALL ENTRIES IN it_ausp_1
WHERE matnr = it_ausp_1-objek AND
werks = p_werks
AND mmsta LE 60.
SORT it_marc BY matnr.
CLEAR wa_ausp_1.
CLEAR wa_tabix.
LOOP AT it_ausp_1 INTO wa_ausp_1.
wa_tabix = sy-tabix.
READ TABLE it_marc INTO wa_marc WITH
KEY matnr = wa_ausp_1-objek
BINARY SEARCH.
IF sy-subrc EQ 0.
ELSE.
DELETE it_ausp_1 INDEX wa_tabix.
ENDIF.
ENDLOOP. " LOOP AT it_ausp_1 INTO wa_ausp_1.
APPEND LINES OF it_ausp_1 TO it_tal.
IF it_tal[] IS NOT INITIAL.
LOOP AT t_plan_order INTO fs_plan_order.
SELECT r~rsnum
r~rspos
r~matnr
r~nomng
r~meins
r~plnum
r~bdter
r~ewahr
r~alprf
r~posnr
r~baugr
m~dispo
INTO TABLE t_resb
FROM resb AS r
INNER JOIN marc AS m
ON rbaugr = mmatnr
AND rwerks = mwerks
FOR ALL ENTRIES IN it_tal
WHERE r~rsnum = fs_plan_order-rsnum
AND r~matnr = it_tal-objek
AND r~xloek = ' '
AND r~werks = p_werks.
APPEND LINES OF t_resb TO t_tacl.
ENDLOOP.SELECT r~rsnum r~rspos r~matnr r~nomng r~meins r~plnum r~bdter r~ewahr r~alprf r~posnr r~baugr m~dispo
INTO TABLE t_resb
FROM resb AS r
INNER JOIN marc AS m
ON r~baugr = m~matnr
AND r~werks = m~werks
FOR ALL ENTRIES IN it_tal
WHERE r~rsnum = fs_plan_order-rsnum
AND r~matnr = it_tal-objek
AND r~xloek = ' '
AND r~werks = p_werks.
The logic of this select is completely weird. Whcih order of the db-tables should be used, which indexes?
On RESB matnr, werks and xloek are in one index, but rsnum not.
Are the conditions in fs_plan_order and it_tal connected or independent?
It is probably much faster, to leave the fs_plan_order condition away and check it on the result.
SELECT r~rsnum r~rspos r~matnr r~nomng r~meins r~plnum r~bdter r~ewahr r~alprf r~posnr r~baugr m~dispo
INTO TABLE t_resb
FROM resb AS r
INNER JOIN marc AS m
ON m~matnr = r~baugr
AND m~werks = r~werks
FOR ALL ENTRIES IN it_tal
WHERE AND r~matnr = it_tal-objek
AND r~xloek = ' '
AND r~werks = p_werks.
sort fs_plan_order by rsnum.
loop at it_tal in wa.
read table fs_plan_order
with key rsnum = wa-rsnum
binary search.
if sy-subrc eq 0.
append ...
endif.
endloop.
Siegfried -
How to avoid using constants ?
Hello,
I am starting a new project and I am thinking of a way to avoid using constants.
For example, in a report, it selects all the order with types ZLN and ZLB.
I know that I have several possibilities :
- hard code it in the program (using constants which I want to avoid)
- create a specific table with all the types that I want to select (this may be the best solution but it can be very long -> too much table to create)
- put the parameter in the selection screen (but then we have to put default values which come back to the same problem)
So, I didn't found any perfect solution, Do you know what is the method recommended by SAP ?
What kind of technics did you use in you projects ?
Thank you for your help !Hi Friend ,
As you taught , there are multiple ways to handle the constants in the program.
But finally time & efficency matters alot .
so my idea would be i will list all the constant & get the quick understanding of the constant type's.
For example : Order type is Customizing data which will maintained by Fun.Consultant , so i will give work for him to maitain the Varient against Order type in the TVARC table .so that in the program i will declare one order type vraible under atselection-screen event i will write select Query to get the vaule from the TVARC table which will be maintaine . we can write the execption also with sy-subrc <> o.if it is not maintianed .so far all customizing data fields this would be the best way for constants maintaining outside your program .
Similarly if any system constants then we can get it in runtime with SYST table parameters .
if there are any ABAP Program Constants ( Titles,labels ,case condition parameters,ect) maintain in the tprogram ext elements , or you can generically maintain a Utility class where you can create an attribute so that whereeven you want you can reuse the same .
Regards, -
How to build an array inside a loop
Hi everyone,
I have a basic question about labview. I would like to create an array in a "for" loop in that way:
inside the loop, if a condition named "A" is verified, then, i add a new value to the first column of the array. Otherwise, i create a new column, and start to add values to this column when the condition "A" is verified, etc.
I put an example of a VI where the condition "A" is "the increment of the loop + 1 is not divisible by 5" and the values of the arrays are the increment of the loop + 1. The loop stops when the increment = 25.
In this example, i have a single column with the values [1 2 3 4 6 7 8 9 11 12 13 14 16 17 18 19 21 22 23 24]
while I would like to have an array of 5 columns:
1 6 11 16 21
2 7 12 17 22
3 8 13 18 23
4 9 14 19 24
Note than this is just an example. More generally, the array can contain columns of different lengths.
Thanx for your answer
Andrew
Solved!
Go to Solution.
Attachments:
build_array.vi 9 KBYou can't have columns in an array have different lengths - you can dynamically increase the size of the array (e.g. build array) but it means you will get the default value of the array in the other columns up to the new size of the array (normally 0).
You will need to either keep track of the last index you wrote to for each column so you can trim it later or put an array in a cluster and then create an array of those (an array of a cluster of an array) - that will allow your column data array to have different lengths and you'll just need to unbundle/bundle the array before adding new items.
Certified LabVIEW Architect, Certified TestStand Developer
NI Days (and A&DF): 2010, 2011, 2013, 2014
NI Week: 2012, 2014
Knowledgeable in all things Giant Tetris and WebSockets -
How to set error message inside the loop...module pool
Dear all,
Am creating Table Control without wizard. In that i am looping the values, that is, Once if i entered 5 digit values means, 12345-08... the values should be stored in z-table like this 12345,12346,12347,12348 . That is 5-8 it as to update in z table. for this i createdloop at itab and inside that i written a code to count the value and all. and also its clearly updating the value in ztable too. now i want to know, if once again i entered the same value means, like 12345-08.. it as to show error messge.I dont know how to set the condition with error message inside the single loop .... Its all comes under module pool program.
Thanks,
Santhosh.RIf i understood your doubt, here goes the answer.
LOOP AT itab INTO wa_itab. " This is your loop
l_tabix = sy-tabix. "l_tabix receives the line of the loop
READ TABLE itab WITH KEY itab = wa_itab. "itab is the same tab of your loop
IF sy-subrc EQ 0 AND l_tabix NE sy-tabix. "Here the sy tabix have the value of the read table.
* Here you do your error treatment.
ENDIF.
ENDLOOP.
Explanation: When you are looping your internal table, you use a READ TABLE to see the already recorded registers. If the read table finds one register (sy-subrc EQ 0) and the this register is not the one of the current line (l_tabix NE sy-tabix). It means you have a duplicated register.
Maybe there is someway easier to do this, but this is what i thought now.
I hope this was your doubt hehe.
Thales Schmidt -
How do I use an enhanced for loop / for each on my ViewObjectImpl ?
Guys and Gals,
With all of my newly acquired Java knowledge in tow, I spent this weekend cleaning up all of my code, dealing mainly with for loops. I converted them from a huge mess to a for each type loop using language such as ...
RowSet priceUpdateRows = (RowSet)((PriceUpdatesViewRowImpl) priceUpdate).getPriceUpdateRowsView();
for (Row priceUpdateRow: priceUpdateRows)
{ // do operations on row... which makes perfect sense to me. For each Row in the RowSet, do something. It doesn't, however, makes sense to the compiler. It pouts and gives me a "foreach not applicable to expression type" error. So I read up on iterators and such, messed with code examples, and still can't get the RowSet to iterate with the above code. Could I make RowSet implement Iterable? How would I do that? I tried to create a class called RowSetExt which extended RowSet and implemented Iterable, but then I got a class cast exception.
I know I could implement something like the following or a while(hasNext()) but they're really not what I'm looking for.
ViewObject vo = … < Get ViewObject > …
RowSetIterator rsi = vo.createRowSetIterator("rowsRSI");
while (rsi.hasNext())
Row row = rsi.next();
row.setAttribute("YourAttribute",your_value);
rsi.closeRowSetIterator();How do I make the for(Row row : <RowSet>) example work? Or could someone point me in a direction?
WillOne thing I tried was to make a framework extension class for my ViewObjectImpls
public class PcsViewObjectImpl
extends ViewObjectImpl
implements Iterable<Row>
Set<Row> set = new HashSet<Row>();
public Iterator<Row> getRows()
return set.iterator();
public Iterator<Row> iterator()
return getRows();
}AppModuleImpl
PriceUpdateRowsViewRowImpl priceUpdateRows = (PriceUpdateRowsViewRowImpl)((PriceUpdatesViewRowImpl) priceUpdate).getPriceUpdateRowsView();
for (Row priceUpdateRow: priceUpdateRows)
{However, this gives me a class cast exception at runtime. But I would think some kind of extension class would be the way to go ... ? -
How to successfully use PrintWriter inside JSP bean?
Hello
I encoutered the following problem. When I was implementing my Bean class, I tried to use PrintWriter as follows:
PrintWriter myOut = new PrintWriter("myfilename");
However, the consequence was that "Cannot resolve symbol where symbol is : constructor PrintWriter (java.lang.String)" I am simply thinking what I just write is no problem, isn't it? Can I have you help?
Help me do.
I want to know what had been wrong and also how I can succeed to make use of PrintWriter inside the bean class?
John Wen
26-August-06I guess that you want to use the PrintWriter of Java 1.5 while you've Java 1.4 installed.
Check the Constructor summary at the JavaDoc of PrintWriter:
1.4: http://java.sun.com/j2se/1.4.2/docs/api/java/io/PrintWriter.html
1.5: http://java.sun.com/j2se/1.5.0/docs/api/java/io/PrintWriter.html -
How do i use Arrays and For Loops in Loading Multiple Images?
I am struggling to load a sequential array of images to appear like a moving image. So when u click the button the images load one after the other.
The code below is what i have so far, but it fails to do what i seek in that there's only one image loading which is the last image in the array, so either because the images are stacking up atop each other, or because i simply dont understand the basics...
And, i am unclear about what you said kglad, that my solution will be more complicated because i need to preload my image sequence and then use a loop to load it?
import flash.net.URLRequest;
import flash.display.Loader;
var count:int = 0;
var imageArray:Array=["1.jpg","2.jpg","3.jpg","4.jpg","5.jpg","6.jpg","7.jpg",
"8.jpg","9.jpg","10.jpg","11.jpg","12.jpg","13.jpg"];
for(var i:uint=0;i<imageArray.length;i++){
var btn:YourButton=new YourButton();
btn.ivar=i;
addChild(btn);
btn.x=0;
btn.y=0;
btn.addEventListener(MouseEvent.CLICK,clickF);
var ldr:Loader=new Loader();
addChild(ldr);
ldr.x=20;
ldr.y=20;
function clickF(e:MouseEvent){
ldr.load(new URLRequest("D:/flash cs5.5/image_sequence/twirlSeq/"+imageArray[e.currentTarget.ivar]));
function loadComplete(e:Event){
// first process loaded image, then...
count++;
if(count < imageArray.length){
loadCurrentImage(); // load the next image
} else {
// sequencial loading complete, carry on to next activity
function loadCurrentImage(){
ldr.load(imageArray[count]);
ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);create a new fla, add btn and add the code i suggested. test.
var count:int;
var imageArray:Array=["1.jpg","2.jpg","3.jpg","4.jpg","5.jpg","6.jpg","7. jpg",
"8.jpg","9.jpg","10.jpg","11.jpg","12.jpg","13.jpg"];
var ldr0:Loader=new Loader();
ldr0.contentLoaderInfo.addEventListener(Event.COMPLETE,loadCompleteF);
var ldr1:Loader=new Loader();
ldr1.contentLoaderInfo.addEventListener(Event.COMPLETE,loadCompleteF);
btn.addEventListener(MouseEvent.CLICK,clickF);
function clickF(e:MouseEvent):void{
// initialize count
count=0;
// call loadF
loadF();
function loadF():void{
// add one of the loaders to the top of the displaylist and load the next image
addChild(this["ldr"+count%2])
this["ldr"+count%2].load(new URLRequest(imageArray[count]));
function loadCompleteF(e:Event):void{
// increment count
count++;
// check if the last has loaded
if(count<imageArray.length){
// if not clear the content out of the next loader.
if(this["ldr"+count%2].content){
this["ldr"+count%2].unloadAndStop();
// and call loadF so the next loader can load the next image in the array
loadF();
} else {
// if the last has loaded.
// last load completed -
How to avoid use of function module in case of background jobs?
Hi ,
I am working a file tranfer interface .Functionality is to extract file either apllication or presentation server , and process the file through bapi , send the result in their respective server. This program should run through batch jobs in background mode.
I am using following function module :
SUBST_GET_FILE_LIS : Get the file list from application server
TMP_GUI_DIRECTORY_LIST_FILES : Get the file list from presentation server
GUI_UPLOad : to extract file data from presentation server
GUI_downLOAD : to download data to presentation server
in case of background job these function modules will not work.... so how to resolve this issue...
what are the methods we can apply?
Thanks & Regards
SandeepHi,
This FM is used to get list of files from Application server (will work in Background). This cannot be used to list files from presentation server. There is no way , by which you can process presentation server files in background mode.
Regards
Vinod -
How to avoid use of to_date and to_char ?
Hi All,
I have table 'sample ' with columns id (number ) and dte (timestamp ) .
CREATE TABLE SAMPLE ( ID NUMBER,DTE TIMESTAMP);
Sample Records like
INSERT INTO SAMPLE VALUES( 1,SYSDATE);
INSERT INTO SAMPLE VALUES( 2,SYSDATE);
INSERT INTO SAMPLE VALUES( 3,SYSDATE+1);
INSERT INTO SAMPLE VALUES( 4,SYSDATE+1);
INSERT INTO SAMPLE VALUES( 5,SYSDATE+3);
After inserting the records the dte will have both date and time.....
My Question is, How to fetch the records for the given date ( not time ) without using to_date,to_char or trunc functions from the table .
For Example,
select * from sample where dte = '22-OCT-2008' ;
Note : '22-OCT-2008' is not exactly a string ,use it as date datatype.
Regards,
Hariharan STPavan Kumar wrote:
Hi,
strange Requirements, try to use substr
SELECT Id , SUBSTR(dte,1,10) FROM SAMPLE
No ! That doesn't give any garuantee about the result !
SQL> select created,substr(created,1,10) from dba_users;
CREATED SUBSTR(CREATED,1,10)
20030527 14:12:47 20030527 1
20030527 14:12:47 20030527 1
20030527 14:12:52 20030527 1
20030527 14:20:54 20030527 1
20030527 14:32:36 20030527 1
20070124 16:59:58 20070124 1
20080811 15:08:13 20080811 1
20080929 10:52:04 20080929 1
20070827 15:16:18 20070827 1
20030818 15:41:05 20030818 1
20030527 14:32:40 20030527 1
CREATED SUBSTR(CREATED,1,10)
20040301 07:04:46 20040301 0
20060830 14:14:25 20060830 1
13 rows selected.Don't use string function against date. Use the proper session parameter setting NLS_DATE_FORMAT as well. And work properly with the date format mask.
Nicolas. -
How to avoid using dataset as data source
Hi all,
using dataset cause producing report slow. could anyone tell me how to use a stored procedure directly as data source?
Thank you very much
ClaraYou may also want to determine where exactly is the slow part of this happening. Remember that to get a report, there is a number of steps, other than connecting and retrieving data from the datasource.
E.g.;
Load of the runtime, load of the report, processing of the report, formatting of the report, etc.
If you do find that datasets are the issue, than Don's suggestion is excellent.
Ludek -
How to avoid using subfolders in libraries and use views to show all data
Hi all
I am very new to Sharepoint design so hopefully I can explain what I need properly.
I have a sharepoint site which I upload a lot of data to. Most of the data I can categorise into subfolders (Location and Year). Instead of having the same subfolders in each library I wanted the user to select the Location and Year they want from a dropdown
and then refresh a List webpart based on their requirements.
Is this easy to do?
Would I have to create new columns called Location and Year in order to do this?
Thanks for any help
RaiyanYes, you can do so.
You can create a view to show data based on location and year
http://blog.pentalogic.net/2008/10/advanced-sharepoint-view-and-filters/
http://howididit-sharepoint.blogspot.in/2012/04/filtering-lookup-columns.html
http://stackoverflow.com/questions/18362853/how-do-i-filter-by-today-and-time-in-sharepoint-list-view
In SharePoint Designer I edit the calm query from my view in Advanced Mode. And I add
IncludeTimeValue="True" in calm tag Value Type="DateTime". I'm filtering my results by time.
<Query>
<OrderBy>
<FieldRef Name="Modified" Ascending="FALSE"/>
</OrderBy>
<Where>
<Or>
<Gt>
<FieldRef Name="Start"/>
<Value Type="DateTime" IncludeTimeValue="True">
<Today/>
</Value>
</Gt>
<Gt>
<FieldRef Name="TimeOver"/>
<Value Type="DateTime" IncludeTimeValue="True">
<Today/>
</Value>
</Gt>
</Or>
</Where>
</Query>Also check thishttp://office.microsoft.com/en-in/sharepoint-server-help/create-list-relationships-by-using-unique-and-lookup-columns-HA101729901.aspx
Maybe you are looking for
-
I have a fairly large spreadsheet which creates layout floorplan maps based on a table of 3,000+ room locations and various cross-referenced attribute lookup tables which add flags & colour coding to the individual rooms. The maps also include a few
-
Can't get Firefox to stop asking for a profile on startup?
Hello, I am currently running Firefox version 3.5.4 on a server that works somewhat like a kiosk. I downloaded the "Full Screen 3.4" Add-On which does what it is supposed to do just fine. I also created a symbolic link to /usr/lib/firefox/firefox exe
-
I registered my Skype account in China nearly 10 years ago. Since then, I've moved internationally but if I want to add credit, Skype always transfers me to a China site which only has Chinese bank payment options. Even if I change my country sett
-
Territory management in CRM 7.0
Hi, I created a territory and assigned rules and employees for it. And in Display relationships views I can find the business partners account which I need. But when I try to created I opportunity and entered the prospect, The territory Id showes "BT
-
Made in DW8 cross browser problems
The two links were made in DW8 ,Mac I see such a difference between Safari and Firefox and even another difference in IE7 windows. Any help getting these to be a little tighter? Done on a page wrapped in a div container using css. first draft draft 2