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
Similar Messages
-
How to retrieve data from inside the folders in SharePoint SSRS
Hi ,
How to get the data from inside the folders and subfolders.
How can I do that.
https://social.msdn.microsoft.com/Forums/en-US/15451351-4ee2-428c-a0b7-135810e4cbfa/action?threadDisplayName=ssrs-reports-sharepoint-list-datasource-how-to-retrieve-items-from-subfolders
Here the information is not given.
Regards
VinodHi Vinodaggarwal87,
According to your description, you want to retrieve data from sharepoint list in a sub folder. Right?
In this scenario, we should select the XML data source type and in the connection string provide the
List.asmx service URL when creating data source. Then we need to use the List web Service and specify "recursive" for ViewAttribute in Lists.asmx. For detail steps, please refer to the links below:
Generate SSRS report on SharePoint List with folders using List Service.
SSRS: how to specify ViewAttributes when creating a report against a SharePoint's list
If you want to set the ViewAttribute on CAML query level. You need add the view tag outside of query tag:
<View Scope="RecursiveAll">
<Query>
<Where>...</Where>
</Query>
</View>
Reference:
View Element (List)
ViewAttributes Recursive Scope not working SharePoint 2013 CAML Query to fetch all files from document library recursively
If you have any question, please feel free to ask.
Best Regards,
Simon Hou -
How to extend data selection to the existing delta update without disturbin
Is there any way to extend data selection to the existing delta update with out disturbing the delta mechanism? I mean, is there anyway to add new delta init for the new data selection to the existing delta update without disturbing?
the scenario is we have existing delta, let's say, for the 2 company codes 0001 and 0002. I want to extract delta for the company code 0003 without disturbing the existing delta mechanism. I mean to say I want to extend the data selection for the existing delta from 2 comp codes (0001, 0002) to 3 company codes (0001,0002 & 0003) without disturbing the delta mechanism.
-
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.
-
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 to avoid end-select in the sel;ect statement
Hi All
i have the following select statement,
SELECT KBETR FROM KONV
INTO (V_EXDUTY) UP TO 1 ROWS
WHERE KNUMV = VBRK-KNUMV
AND KSCHL = 'JEXP'
AND KPOSN = VBFA-POSNN.
ENDSELECT.
now i want to know the alternative stat for this one by removing the end-select. and also explain me why do we use select ..... end-select. brief explanation is appreciated.
thanks in advance
ABAPERhi,
u can use SELECT SINGLE ...since u r using select upto 1 rows. they hv used select upto 1 rows...as they are passing partial primary keys. there is a possibility that u mite have more than one matching records.
u can use "select..into table" and use some condition to retrieve the specific record.
regards,
madhu -
How to avoid the loop inside the loop? as it reduces the performance.
hi masters,
i have 2 internal tables having 1 same field. eg table itab having f1, f2, f3 fields and itab1 having f1, f4 and f5 fields. let us consider the data in the itab and itab1 is like below given
itab-f1 itab-f2 itab-f3 itab1-f1 itab1-f4 itab1-f5
10 aa 11 10 abc 456
10 bb 15 10 def 655
10 ff 13 10 ghi 456
11 dd 16 10 tre 455
11 zz 24 11 ftr 256
11 ii 54 11 kjh 556
12 hh 24 12 fjk 751
now i want the result in final table like below
f1 f2 f3 f4 f5
10 aa 11 abc 456
10 aa 11 def 655
10 aa 11 ghi 456
10 aa 11 tre 455
10 bb 15 abc 456
10 bb 15 def 655
10 bb 15 ghi 456
10 bb 15 tre 455
10 ff 13 abc 456
10 ff 13 def 655
10 ff 13 ghi 456
10 ff 13 tre 455
11 dd 16 ftr 256
11 dd 16 kjh 556
11 zz 24 ftr 256
11 zz 24 kjh 556
11 ii 54 ftr 256
11 ii 54 kjh 556
12 hh 24 fjk 751
i can get this result using the
Loop at itab.
loop at itab1 where f1 = itab-f1.
process....
endloop.
endloop.
but it is very slow. i want to avoid this loop inside the loop and i want to implement the same program using read table.. like below..
Loop at itab.
Read table itab1 with key ....
process...
endloop.
Is it possible? to get multiple records from itab2 using read statement or with READ statement that using CASE Statement or IF statemetnt.
Plz help me...hi,
please try the following code
TYPES:
begin of ty_itab2,
f1
f2
f3
f4
f5
end of ty_itab2.
DATA:
lw_tab2tmp type ty_itab2,
lt_tab2tmp type standard table of ty_itab2.
sort it_itab by f1.
loop at it_itab into lw_itab.
at new f1.
CLEAR lt_tab2tmp[].
loop at it_itab1 into lw_itab1 where f1 = lw_itab-f1.
CLEAR lw_tab2tmp.
move-corresponding lw_itab1 to lw_tab2tmp.
append lw_tab2tmp into lt_tab2tmp.
end loop.
"while there is no data with f1 in it_itab1
if lt_tab2tmp is initial.
lw_tab2tmp-f1 = lw_itab-f1.
append lw_tab2tmp into lt_tab2tmp.
endif.
end at.
CLEAR lw_tab2tmp.
MOVE-CORRESPONDING lw_itab to lw_tab2tmp.
modify lt_tab2tmp from lw_tab2tmp TRANSPORTING f2 f3 where not f1 is initial.
append lines of lt_tab2tmp into lt_itab2.
end loop.
lt_itab2 is the final table.
There may be some syntactically errors.
I have not a system to test it now, please test it. -
How to avoid data repetation when using select statements with innerjoin
how to avoid data repetation when using select statements with innerjoin.
thanks in advance,
satheeshyou can use a query like this...
SELECT DISTINCT
frg~prc_group1 "Product Group 1
frg~prc_group2 "Product Group 2
frg~prc_group3 "Product Group 3
frg~prc_group4 "Product Group 4
frg~prc_group5 "Product Group 5
prc~product_id "Product ID
txt~short_text "Product Description
UP TO 10 ROWS
INTO TABLE l_i_data
FROM
Joining CRMM_PR_SALESG and
COMM_PR_FRG_ROD
crmm_pr_salesg AS frg
INNER JOIN comm_pr_frg_rod AS prd
ON frgfrg_guid = prdfragment_guid
Joining COMM_PRODUCT and
COMM_PR_FRG_ROD
INNER JOIN comm_product AS prc
ON prdproduct_guid = prcproduct_guid
Joining COMM_PRSHTEXT and
COMM_PR_FRG_ROD
INNER JOIN comm_prshtext AS txt
ON prdproduct_guid = txtproduct_guid
WHERE frg~prc_group1 IN r_zprc_group1
AND frg~prc_group2 IN r_zprc_group2
AND frg~prc_group3 IN r_zprc_group3
AND frg~prc_group4 IN r_zprc_group4
AND frg~prc_group5 IN r_zprc_group5.
reward it it helps
Edited by: Apan Kumar Motilal on Jun 24, 2008 1:57 PM -
How to check data type of the field symbol at run time
Hi,
My code is as following:
LOOP AT <fs> ASSIGNING <wa_covp_ext>.
ASSIGN COMPONENT 86 OF STRUCTURE <wa_covp_ext> TO <f_zzname>.
IF sy-subrc = 0.
ASSIGN COMPONENT 158 OF STRUCTURE <wa_covp_ext> TO <f_pernr>.
IF sy-subrc = 0.
SELECT SINGLE sname INTO <f_zzname> FROM pa0001
WHERE pernr = <f_pernr>
AND endda GE sy-datum
AND begda LE sy-datum.
ENDIF.
ENDIF.
ENDLOOP.
This query is giving dump when <f_zzname> is type P length 8 and decimals 2, because it tries to put PA0001-sname into it which is type C length 30. So I want to check the type of <f_zzname> before the select statement. If it is character 30, then I will write the select statement else not.
How to check data type of the field symbol at run time? If it's not possible, then can somebody suggest a workaround? Thanks.check this ...
write describe statement ...
field-symbols : <f_zzname> .
data : sname like pa0001-sname,
typ(10).
assign sname to <f_zzname>.
describe field <f_zzname> type typ.
write : typ. <-- typ contains character type in this case ..
U can check if typ is of character(C) if so .. write the select statement ... -
Last value from a loop and values inside the loop
Hi
Sorry about the confusing heading above, but its late at night and better words do not occur to me rightaway. Let me explain my situation.
I have a single instrument (a voltage source) that is being swept from one value to another for an experiment. It has three VI's : 1. enable o/p. 2. Set a voltage output level. 3. diable o/p.
I am using the error in and error out pins of instrument vis to properly sequence operations. I connect the error out pin of VI 1 to the error in pin of VI 2. Each of these errors is a cluster of three values.
When I try to wire the error out from VI 2 inside the loop to VI 3 outside the loop, the wiring breaks as I am then trying to connect an array (a 1 dimensional n member array of error outs) to a single error in pin. Trying to connect it to an array outside the loop is obviously the same. (I am making an assumption here - while the loop is running, I do not need to make certain of the sequencing of operations by putting a feedback node on VI 2 - that would mean something quite different in any case.).
So, how do I pass the last value (in this case, the error out cluster from the last stage) to error in pin of VI 3 ?
I have read that it might be possible using shift registers. I am quite new to LabVIEW. A somewhat detailed description of what I need to do would be nice.
Thanks.Hello,
There are basically two options:
Handle the errors outside the for-loop
Handle the errors inside the for-loop
For you solution 1 is the easiest achievable, after the for loop use the 'Merge Errors' VI this will change the 1d-array into a cluster. The downside is that if an error occured later states of the loops don't know this
Solution 2 uses the shift register you mentioned. To use this you have to right-click on the right hand-side tunnel of the error wire (where it leaves the for-loop) and select shift register, sequentially your mouse pointer changes into an downpointed arrow, click on the entry tunnel on the left of the for-loop. What happens is that an error in the for loop is remembered into the next iteration (use execution highlighting to watch these)
Here is some code:
A good start might be:
The link to the LabVIEW Learning Center is here
Ton
Message Edited by TonP on 09-25-2006 08:01 AM
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas
LabVIEW, programming like it should be!
Attachments:
Example_BD.png 5 KB -
How to get updated values from the loops while they are running
Hello,
I am having difficulty solving a very basic problem, how to access the updated values from the 'FOR loop' while its running? Basically, the VI I am currently working on calls two sub VIs. Each sub VI has a for loop, and both VIs may or may not run for same number of iterations. My goal is to read the values at each terminal inside the loop of both sub VIs, in the Main VI. I tried to achieve it using Global Variables, but in main VI it displays only the last iteration value from both sub VIs. Could anyone please tell me whrere am I going wrong? Is there any other/better way to achieve this.
I appreciate any input on this issue.
Kudos are (always) welcome for the good post. :-)
Solved!
Go to Solution.Dennis,
In attached VI, I can see the values changing in the sub VI from the main VI with the numeric indicator whose reference is passed on to the sub VI. Now if I wanted to store or use those values how do I do that? I tried to chnge the indicator to control and read from it (in the attached VI) , but the the indicator updates only once. Tried to create a property node and read the Value from it and it didn't work either.
Thanks in Advance!
-Nilesh
Kudos are (always) welcome for the good post. :-)
Attachments:
main-1.vi 8 KB
sub-1.vi 9 KB -
How to avoid default selection screen in HR interfaces(using pnp ldbs)
How to avoid default selection screen in HR interfaces(using pnp ldbs)
Dear Rakesh,
The report category is used to change the selection screen of programs that use the 'PNP' logical database.
See links bellow:
http://www.sapdevelopment.co.uk/hr/hr_repcat.htm
http://help.sap.com/saphelp_erp2005/helpdata/en/15/229357553611d3967f00a0c9306433/frameset.htm
Report categories for selection screen in HR programming
Also visit the following blog:
/people/alvaro.tejadagalindo/blog/2006/02/19/how-to-deal-with-hr-payroll-reports
Regards,
Naveen. -
How to output data outtside a for loop every 10 iterations​?
Hi friends,
does any body help me to sort out this problem?
please check the attchement for my vi.
all i want is output data from inside for loop to outside for loop every 10 iterations. please do not use local variable.
Many thanks
dan
Attachments:
output.vi 16 KBHi Dan,
I am not sure what you want to do every 10 iterations with the value outside, but If you want to update your graph every 10 iterations use the following way:
If you want to handle the specific value every x iterations outside the loop you could either use queues or notifieres.
BR,
ThSa
Message Edited by ThSa on 08-23-2006 09:05 PM
http://www.newgistics.com
Attachments:
1.png 6 KB -
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 -
Hi How do we create Methods inside the Business objects of Z
Hi Abapers,
How do we create Methods inside the Business objects (z objects) and how *** an import parameter or export parameter to be defined for the new Methods.
Regards
Bhaskar Rao.MHi Bhaskar,
that ´s not difficult.
Open your Bus.Obj. in SWO1 with CHANGE/EDIT
Click on the "Methods" header line and then use the button for "Create".
If you want to add the method on basis of a function module, choose next in the next pop up. Then the system will offer you the ex/import parameter from the function module. So this is a really simple way.
If you don´t have a FM, it is a little bit more difficult.
Choose No on the quetion about a FM, fill in the next pop up methode name (no blanks allowed).
Dialogue is for user related method (call screen...) synchronous for methods which have to give back a result directly in to the workflow.
After completing the screen the method will be displayed as new method at the end of method list. Now add parameters (first click on the method name, then choose parameter button, same functionality to add program to the method).
Programm:
Code snip:
BEGIN_METHOD ZWFCHECKMIRO CHANGING CONTAINER.
DATA:
ZBELNR TYPE RBKP-BELNR,
ZGJAHR TYPE RBKP-GJAHR,
RESULT TYPE HRP1001-ISTAT,
BELNR TYPE BKPF-BELNR,
GJAHR TYPE BKPF-GJAHR,
BUKRS TYPE BKPF-BUKRS.
to import parameter
SWC_GET_ELEMENT CONTAINER 'Zbelnr' ZBELNR.
SWC_GET_ELEMENT CONTAINER 'Zgjahr' ZGJAHR.
*(or SWC_GET_TABLE)
here add the functionality of your method!
to export parameter
SWC_SET_ELEMENT CONTAINER 'Result' RESULT.
SWC_SET_ELEMENT CONTAINER 'Belnr' BELNR.
*(or SWC_SET_TABLE)
!!! Important: naming convention!!! Use same writing of parameter names in
PARAM area (button PARAMETER) and here in code.
To use your method, change it to implemented after adding your code.
-> Edit -> Change release status -> object type component -> into implemented
(Sorry , have a german screen here, possibly terms are a little bit different.
Hope this helps a little bit.!
regards
Dirk
Maybe you are looking for
-
We have several plugins that in the past successfully ran in other Mozilla based browsers such as K-Meleon, Sea-Monkey, Netscape, etc. In the past the plugin needed to be manually installed or required a special downloadable installer to get the plug
-
Upgrade to 10.8 broke all (?) aliases
Yesterday, I upgraded from 10.7.5 to 10.8.3 via App Store. As I've gingerly returned to work post-upgrade, everything seems OK so far, except: Most (all?) of my existing aliases are broken. Never had any particular problem with aliases before. N
-
Command Link inside table to external website in popup window
Hi, I am trying to have a command link inside a table which is on the tables id. I know that if I have control of the destination page I can use setCurrentRowKeyValue. However I do not have control of the external website. So I cannot add it into my
-
Using Windows Media Player to transfer fi
Hello all! This is my first post to the forum. I received a Nomad Jukebox Zen Xtra 60GB for Christmas and have encountered a few problems. I am using WMP for transfering files to the player and after during the transfer of the 5th album, the last fi'
-
Installming on portable hard drive
According to the licensing agreement, I can also install the Dreamweaver program on a portable storage drive -- which I have done so that I can bring it to work and during my down time, work on some of my projects. However, when I plugged in my porta