Duplicate value in Command extract report
Hi Experts
I am getting a duplicate record when extracting the BOM which is so called Material Extract in my words
when running the report I am getting the duplicate value for the cost estimate. near the form extract_bom_details under select queries
Can anyone help me why I am getting so by seeing the coding please.
TYPES:
BEGIN OF ty_bom,
matnr(12) TYPE c, " Material #
werks(4) TYPE c, " Plant
stprs(10) TYPE c, " Quantity
meins(3) TYPE c, " Unit of Measure
END OF ty_bom,
it_ty_bom TYPE ty_bom OCCURS 0,
*Start of block of changes for JPC20061107
BEGIN OF ty_bom_sapfmt,
matnr TYPE MARC-MATNR, " Material #
werks TYPE MARC-WERKS, " Plant
stprs TYPE MBEW-STPRS, " Quantity
meins TYPE MARA-MEINS, " Unit of Measure
END OF ty_bom_sapfmt.
Report COMMAND_EXTRACT_D *
REPORT command_extract_d .
*CLASS cl_gui_control DEFINITION LOAD.
*CLASS cl_gui_frontend_services DEFINITION LOAD.
Tables
TABLES:
kna1,
knb1,
knvv,
mara,
mast, "JPC20061107
marc,
makt,mbew,
sscrfields.
CONSTANTS: BEGIN OF gc_status,
acc TYPE zcrstat1 VALUE ' ACC',
hol TYPE zcrstat1 VALUE ' HOL',
sto TYPE zcrstat1 VALUE ' STO',
ok TYPE zcrstat1 VALUE ' OK',
hold TYPE zcrstat1 VALUE 'HOLD',
END OF gc_status.
CONSTANTS: BEGIN OF gc_reason,
000 TYPE zreason VALUE '000',
001 TYPE zreason VALUE '001',
002 TYPE zreason VALUE '002',
003 TYPE zreason VALUE '003',
004 TYPE zreason VALUE '004',
005 TYPE zreason VALUE '005',
006 TYPE zreason VALUE '006',
007 TYPE zreason VALUE '007',
008 TYPE zreason VALUE '008',
010 TYPE zreason VALUE '010',
011 TYPE zreason VALUE '011',
021 TYPE zreason VALUE '021',
022 TYPE zreason VALUE '022',
023 TYPE zreason VALUE '023',
024 TYPE zreason VALUE '024',
025 TYPE zreason VALUE '025',
026 TYPE zreason VALUE '026',
999 TYPE zreason VALUE '999',
END OF gc_reason.
TYPES: BEGIN OF ty_kna1_fields,
kunnr TYPE kna1-kunnr,
sperr TYPE kna1-sperr,
aufsd TYPE kna1-aufsd,
lifsd TYPE kna1-lifsd,
faksd TYPE kna1-faksd,
loevm TYPE kna1-loevm,
END OF ty_kna1_fields.
TYPES: BEGIN OF ty_knb1_fields,
kunnr TYPE knb1-kunnr,
bukrs TYPE knb1-bukrs,
sperr TYPE knb1-sperr,
loevm TYPE knb1-loevm,
END OF ty_knb1_fields.
TYPES: BEGIN OF ty_knvv_fields,
kunnr TYPE knvv-kunnr,
vkorg TYPE knvv-vkorg,
vtweg TYPE knvv-vtweg,
spart TYPE knvv-spart,
aufsd TYPE knvv-aufsd,
lifsd TYPE knvv-lifsd,
faksd TYPE knvv-faksd,
END OF ty_knvv_fields.
TYPES: BEGIN OF ty_knkk_fields,
kunnr TYPE knkk-kunnr,
kkber TYPE knkk-kkber,
ctlpc TYPE knkk-ctlpc,
crblb TYPE knkk-crblb,
knkli TYPE knkk-knkli,
klimk TYPE knkk-klimk,
skfor TYPE knkk-skfor,
ssobl TYPE knkk-ssobl,
END OF ty_knkk_fields.
TYPES: BEGIN OF ty_cust_stat_output,
kunnr(10) TYPE c, "Customer #
stat(4) TYPE c, "Customer status
END OF ty_cust_stat_output.
TYPES:
BEGIN OF ty_customers,
kunnr(10) TYPE c, " Customer #
div1(1) TYPE c, " Pipe delimiter
name1(32) TYPE c, " Customer name
div2(1) TYPE c, " Pipe delimiter
altkn(8) TYPE c, " Old Customer #
div3(1) TYPE c, " Pipe delimiter
stras(30) TYPE c, " Street
div4(1) TYPE c, " Pipe delimiter
ort01(20) TYPE c, " City
div5(1) TYPE c, " Pipe delimiter
regio(3) TYPE c, " State
div6(1) TYPE c, " Pipe delimiter
pstlz(4) TYPE c, " Postcode
div7(1) TYPE c, " Pipe delimiter
telf1(14) TYPE c, " Phone 1
div8(1) TYPE c, " Pipe delimiter
telf2(14) TYPE c, " Phone 2
div9(1) TYPE c, " Pipe delimiter
erdat(10) TYPE c, " date
div10(1) TYPE c, " Pipe delimiter
splant(2) TYPE c, " plant
div11(1) TYPE c, " Pipe delimiter
END OF ty_customers,
it_ty_customers TYPE ty_customers OCCURS 0,
BEGIN OF ty_custstat,
kunnr(11) TYPE c, " Customer #
company(2) TYPE c, " #
status(3) TYPE c, " acc,cod,hol,
END OF ty_custstat,
it_ty_custstat TYPE ty_custstat OCCURS 0.
TYPES:
BEGIN OF ty_materialm,
matnr(12) TYPE c, " Material #
maktx2(40) TYPE c, " Command sales desc.
maktx(16) TYPE c, " Basic description
extwg(6) TYPE c, " External Material Group
flag1(1) TYPE c, "
flag2(1) TYPE c, "
flag3(1) TYPE c, "
flag4(1) TYPE c, "
END OF ty_materialm,
it_ty_materialm TYPE ty_materialm OCCURS 0,
BEGIN OF ty_materialp,
matnr(12) TYPE c, " Material #
werks(4) TYPE c, " plant
batch(1) TYPE c, " download to batch
END OF ty_materialp,
it_ty_materialp TYPE ty_materialp OCCURS 0.
TYPES:
BEGIN OF ty_bom,
matnr(12) TYPE c, " Material #
werks(4) TYPE c, " Plant
stprs(10) TYPE c, " Quantity
meins(3) TYPE c, " Unit of Measure
END OF ty_bom,
it_ty_bom TYPE ty_bom OCCURS 0,
*Start of block of changes for JPC20061107
BEGIN OF ty_bom_sapfmt,
matnr TYPE MARC-MATNR, " Material #
werks TYPE MARC-WERKS, " Plant
stprs TYPE MBEW-STPRS, " Quantity
meins TYPE MARA-MEINS, " Unit of Measure
END OF ty_bom_sapfmt.
Selection screen definition
SELECTION-SCREEN: BEGIN OF BLOCK bom WITH FRAME TITLE text-004.
PARAMETERS:
p_dbom LIKE filepath-pathintern DEFAULT 'Z_COMMAND_BOM_EXTRACT',
p_fbom LIKE rlgrap-filename.
SELECT-OPTIONS:
s_bmatnr FOR MARA-MATNR, "JPC20061107
s_bwerks FOR MAST-WERKS no-extension no intervals, "JPC20061107
s_bextwg FOR mara-extwg.
SELECTION-SCREEN: END OF BLOCK bom.
SELECT-OPTIONS:
s_kunnr FOR kna1-kunnr.
SELECTION-SCREEN: END OF BLOCK ccst.
DATA: clsdir TYPE REF TO cl_gui_frontend_services.
DATA: strfolder TYPE string.
DATA: folderln TYPE i.
DATA: gva_error(1) TYPE c VALUE ' '.
Initial procedure on START ***************
INITIALIZATION.
p_fcust = 'CUST.prn'.
p_fmatm = 'MATM.prn'.
p_fmatp = 'MATP.prn'.
p_fbom = 'BOM.prn'.
p_fccst = 'CCSTAT.prn'.
p_fccst2 = 'CCSTATC.prn'.
p_fccstl = 'CCSTATL.prn'.
s_dextwg-option = 'BT'.
s_dextwg-low = '1'.
s_dextwg-high = '8'.
APPEND s_dextwg.
s_bextwg-option = 'BT'.
s_bextwg-low = '1'.
s_bextwg-high = '1'.
APPEND s_bextwg.
AT SELECTION-SCREEN.
IF p_ccust EQ 'X' AND ( p_fcust IS INITIAL OR p_dcust IS INITIAL ).
MESSAGE s000(zppu)
WITH 'You must specify the file details for the customer data'.
gva_error = 'X'.
ENDIF.
IF p_cmatm EQ 'X' AND ( p_fmatm IS INITIAL OR
p_fmatp IS INITIAL OR
p_dmatm IS INITIAL ).
MESSAGE s001(zppu)
WITH 'You must specify the file details for the material data'.
gva_error = 'X'.
ENDIF.
IF p_cbom EQ 'X' AND ( p_fbom IS INITIAL OR p_dbom IS INITIAL ).
MESSAGE s002(zppu)
WITH 'You must specify the file details for the BOM data'.
gva_error = 'X'.
ENDIF.
IF p_cbom EQ 'X'.
IF s_bwerks-low is initial.
MESSAGE s002(zppu)
WITH 'You must specify a plant to run BOM extract for'.
gva_error = 'X'.
ENDIF.
IF LINES( s_bwerks ) > 1.
MESSAGE s002(zppu)
WITH 'You can only specify 1 plant for BOM extract'.
gva_error = 'X'.
ENDIF.
ENDIF.
IF p_ccst EQ 'X' AND ( p_fccst IS INITIAL OR
p_fccst2 IS INITIAL OR
p_fccstl IS INITIAL OR
p_dccst IS INITIAL ).
MESSAGE s002(zppu)
WITH 'You must specify the file details for the customer'
'status data'.
gva_error = 'X'.
ENDIF.
AT SELECTION-SCREEN OUTPUT.
PERFORM user_command.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_fcust.
PERFORM get_gui_filename USING p_dcust p_fcust.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_fmatm.
PERFORM get_gui_filename USING p_dmatm p_fmatm.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_fmatp.
PERFORM get_gui_filename USING p_dmatm p_fmatp.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_fbom.
PERFORM get_gui_filename USING p_dbom p_fbom.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_fccst.
PERFORM get_gui_filename USING p_dccst p_fccst.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_fccst2.
PERFORM get_gui_filename USING p_dccst p_fccst2.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_fccstl.
PERFORM get_gui_filename USING p_dccst p_fccstl.
END-OF-SELECTION.
Data selection execution.
DATA: lwa_kna1 TYPE kna1,
lwa_knb1 TYPE knb1,
lwa_knvv TYPE knvv.
DATA: lwa_marc TYPE marc,
lwa_mara TYPE marav,
lwa_makt TYPE makt.
DATA: lit_marav TYPE marav OCCURS 0.
DATA: lit_customers TYPE it_ty_customers,
lwa_customers TYPE ty_customers.
DATA: lit_custstat TYPE it_ty_custstat,
lwa_custstat TYPE ty_custstat.
DATA: lit_materialm TYPE it_ty_materialm,
lwa_materialm TYPE ty_materialm.
DATA: lit_materialp TYPE it_ty_materialp,
lwa_materialp TYPE ty_materialp.
*(del)DATA: lwa_bomlist TYPE ty_bomlist, "JPC20061107
*(del) lit_bomlist TYPE it_ty_bomlist. "JPC20061107
DATA: lwa_bom TYPE ty_bom_sapfmt,
lit_bom TYPE it_ty_bom WITH HEADER LINE. "JPC20061107
lit_bom TYPE it_ty_bom. "JPC20061107
DATA: output_file TYPE string.
DATA: lock_file TYPE string.
DATA: lva_mssage TYPE string.
DATA: lva_matnr(18) TYPE n.
DATA: lva_date TYPE datum.
DATA: txtper(3) TYPE c.
DATA: custper TYPE i.
DATA: custcount TYPE i.
DATA: itemnum TYPE i.
CHECK gva_error <> 'X'.
IF p_ccust EQ 'X'. " Do the customer file extract
PERFORM extract_customer_details.
ENDIF.
IF p_cmatm EQ 'X'. " Do the Material file extract
PERFORM extract_material_details.
ENDIF.
IF p_cbom EQ 'X'. " Do the BOM file extract
PERFORM extract_bom_details.
ENDIF.
IF p_ccst EQ 'X'. " Do the customer credit status file extract
PERFORM extract_credit_status_details.
ENDIF.
*& Form extract_customer_details
text
--> p1 text
<-- p2 text
FORM extract_customer_details.
SELECT * FROM knb1
INTO lwa_knb1
WHERE bukrs = p_dcomp.
MOVE-CORRESPONDING lwa_knb1 TO lwa_customers.
MOVE-CORRESPONDING lwa_knb1 TO lwa_custstat.
MOVE '#' TO lwa_custstat-company.
MOVE p_dwerk TO lwa_customers-splant.
--WG1K903075: Start Delete-
move: '|' to lwa_customers-div1,
'|' to lwa_customers-div2,
'|' to lwa_customers-div3,
'|' to lwa_customers-div4,
'|' to lwa_customers-div5,
'|' to lwa_customers-div6,
'|' to lwa_customers-div7,
'|' to lwa_customers-div8,
'|' to lwa_customers-div9,
'|' to lwa_customers-div10,
'|' to lwa_customers-div11.
--WG1K903075: End Delete---
--WG1K903075: Start Insert-
MOVE: ' ' TO lwa_customers-div1,
' ' TO lwa_customers-div2,
' ' TO lwa_customers-div3,
' ' TO lwa_customers-div4,
' ' TO lwa_customers-div5,
' ' TO lwa_customers-div6,
' ' TO lwa_customers-div7,
' ' TO lwa_customers-div8,
' ' TO lwa_customers-div9,
' ' TO lwa_customers-div10,
' ' TO lwa_customers-div11.
--WG1K903075: End Insert---
APPEND lwa_customers TO lit_customers.
APPEND lwa_custstat TO lit_custstat.
ENDSELECT.
DESCRIBE TABLE lit_customers LINES custcount.
LOOP AT lit_customers INTO lwa_customers.
txtper = 100 * sy-tabix / custcount.
custper = txtper.
SELECT SINGLE * FROM kna1
INTO lwa_kna1
WHERE kunnr = lwa_customers-kunnr.
MOVE-CORRESPONDING lwa_kna1 TO lwa_customers.
lva_date = lwa_customers-erdat.
CALL FUNCTION 'CONVERT_DATE_TO_EXTERNAL'
EXPORTING
date_internal = lva_date
IMPORTING
date_external = lwa_customers-erdat
EXCEPTIONS
date_internal_is_invalid = 1
OTHERS = 2.
REPLACE ALL OCCURRENCES OF '.'
IN lwa_customers-erdat WITH '/'.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
input = lwa_customers-kunnr
IMPORTING
output = lwa_customers-kunnr.
WRITE: lwa_customers-kunnr RIGHT-JUSTIFIED TO lwa_customers-kunnr.
MODIFY lit_customers FROM lwa_customers.
Percentage indicator display
lva_mssage = 'Extracting customers'.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
percentage = custper
text = lva_mssage.
ENDLOOP.
IF p_gui IS INITIAL.
PERFORM get_file_path USING p_dcust p_fcust output_file.
OPEN DATASET output_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc EQ 0.
LOOP AT lit_customers INTO lwa_customers.
TRANSFER lwa_customers TO output_file.
ENDLOOP.
CLOSE DATASET output_file.
ELSE.
MESSAGE s002(zppu)
WITH 'Dataset' output_file 'cannot be opened on the server'.
ENDIF.
ELSE.
MOVE p_fcust TO output_file.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = output_file
filetype = 'ASC'
TABLES
data_tab = lit_customers
EXCEPTIONS
OTHERS = 11.
ENDIF.
output_file = custcount.
CONCATENATE
output_file
' Customers extracted'
INTO
lva_mssage.
message lva_mssage type 'I'.
ENDFORM. " extract_customer_details
*& Form extract_bom_details
text
--> p1 text
<-- p2 text
FORM extract_bom_details.
select MARAMATNR MBEWBWKEY MBEWSTPRS MARAMEINS "JPC20061220
into lwa_bom
from ( MARAV AS MARA
inner join MARC
ON MARAMATNR = MARCMATNR
INNER join MBEW
ON MARCMATNR = MBEWMATNR
AND MARCWERKS = MBEWBWKEY
where MARA~MATNR in s_bmatnr
and MBEW~BWKEY in s_bwerks
and MARA~EXTWG in s_bextwg.
clear lit_bom.
WRITE lwa_bom-matnr TO lit_bom-matnr.
MOVE lwa_bom-werks TO lit_bom-werks.
MOVE: lwa_bom-stprs TO lit_bom-stprs,
lwa_bom-meins TO lit_bom-meins.
APPEND lit_bom.
ENDSELECT.
SORT lit_bom ascending.
Ending for lines inserted for change 20061107
IF p_gui IS INITIAL. "write to server
PERFORM get_file_path USING p_dbom p_fbom output_file.
OPEN DATASET output_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc EQ 0.
custcount = lines( lit_bom ).
LOOP AT lit_bom.
txtper = 100 * sy-tabix / custcount.
custper = txtper.
lva_mssage = 'Extracting material B.O.Ms'.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING percentage = custper
text = lva_mssage.
TRANSFER lit_bom TO output_file.
ENDLOOP.
CLOSE DATASET output_file.
ELSE.
MESSAGE s002(zppu)
WITH 'Dataset' output_file 'cannot be opened on the server'.
ENDIF.
ELSE.
MOVE p_fbom TO output_file.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = output_file
filetype = 'ASC'
write_field_separator = ' '
TABLES
data_tab = lit_bom
EXCEPTIONS
OTHERS = 11.
ENDIF.
ENDFORM. " extract_bom_details
output with duplicate values
MARA BWKEY STPRS MEINS
10004989 BN01 28.00 TO
10004989 BN01 28.00 TO
10005010 BN01 19.00 EA
10005010 BN01 19.00 EA
10005018 BN01 800.00 BAG
10005018 BN01 800.00 BAG
10005115 BN01 82.74 TO
10005115 BN01 82.74 TO
10005117 BN01 137.30 TO
10005117 BN01 137.30 TO
Regards
Piroz
Hi,
Use this statement then duplicate entries removed.
DELETE ADJACENT DUPLICATES FROM table-field.
regards,
Lakshminarayana
Similar Messages
-
Omit Duplicate value in D/N report
Dear Expert,
I have a report based on outbound Delivery.
Data showing in my report with duplicate value.
Delivery Item Condition value
3600000016 90001 2,169,180.00
3600000016 90002 2,169,180.00
3600000016 90003 2,169,180.00
But I need to my report report like:
3600000016 90001 2,169,180.00
3600000016 90002
3600000016 90003
Thanks & B.RgdsHi,
Apply the below logic.
data: wa like itab,
v_count type i.
loop at itab.
if v_count > 0.
if itab-deliveryitem = wa-deliveryitem and
itab-condition = wa-condition and
itab-value = wa-value.
clear: itab-condition, itab-value.
modify itab.
else.
wa-deliveryitem = itab-deliveryitem.
wa-condition = itab-condition.
wa-value = itab-value.
endif.
else.
wa-deliveryitem = itab-deliveryitem.
wa-condition = itab-condition.
wa-value = itab-value.
endif.
v_count = v_count + 1.
endloop. -
Showing only the duplicate values in a webi report.
Hi, I have a unique identifier in my table which is not unique as we are not correctly maitaining the data, I am looking for a way in Webi to list out only the duplicate numbers in the table for that unique object as an audit report so I can make sure it remains clean with no duplicates. Any suggestions on an easy way to do this?
Create a Row Count Measure, as the value being 1, in your Universe for the report. Add that Row Count into the query for the report, re-execute the query, highlight the entire report and then set a filter for that by dragging and dropping the Row Count Measure and filtering where the value > 1.
Edited by: Dennis Scoville on Jul 27, 2009 11:29 AM -
Bringing Duplicate values in OBIEE Answers report
Hi Experts
Need you advise on the below:
I need to bring the duplicate rows in obiee11g report. I have a seq. generator which makes the complete row unique.
But the problem is Business User doesn't want to bring that column in report and then hide it.
I also unchecked "DISTINCT SUPPORTED" plus few more parameters in teh DB properties but no help.
Pls. guide how to achieve it on rpd level so that user doesn't have to drag the column to get duplicate rows.
Appreciat any guidance.Hi
I tried the solution but it didn't work .
These 9 records come when I don't bring the unique identifier in the report request
2013 November FirstNameA LastNameA 1851
2013 November FirstNameB LastNameB V594
2013 November FirstNameC LastNameC 1851
2013 November FirstNameD LastNameD V594
2013 November FirstNameE LastNameE V594
2013 November FirstNameG LastNameG 1851
2013 November FirstNameH LastNameH 1851
2013 November Samuel Ian 1775
2013 November Sandra David 1775
These 10 records come when I bring the unique identifier in the report request . See for - FirstNameE LastNameE
The user wants to see both the rows without actually dragging the unique identifier.
2013 November 16 Sandra David 1775
2013 November 17 FirstNameA LastNameA 1851
2013 November 18 FirstNameB LastNameB V594
2013 November 19 FirstNameC LastNameC 1851
2013 November 20 FirstNameD LastNameD V594
2013 November 21 FirstNameE LastNameE V594
2013 November 22 FirstNameE LastNameE V594
2013 November 23 FirstNameG LastNameG 1851
2013 November 24 FirstNameH LastNameH 1851
2013 November 25 Samuel Ian 1775 -
How to delete duplicate value in movement type 541 & 542(alv report)
hi experts,
i have some problem in alv report,
input we can give some movement type for ex(101,102,541,542, etc)
how to delete duplicate value in 541 and 542.
regards
gunasekaran.Try:
Delete adjacent duplicates from ITAB comparing FIELD1, FIELD2.
to do this the ITAB must be Sorted first.! -
Unable to Enforce Unique Values, Duplicate Values Exist
I have list in SP 2010, it contains roughly 1000 items. I would like to enforce unique values on the title field. I started by cleaning up the list, ensuring that all items already had a unique value. To help with this, I used the export
to excel action, then highlight duplicates within Excel. So as far as I can tell, there are no duplicates within that list column.
However, when I try to enable the option to Enforce Unique Values, I receive the error that duplicate values exist within the field and must be removed.
Steps I've taken so far to identify / resolve duplicate values:
- Multiple exports to Excel from an unfiltered list view, then using highlight duplicates feature > no duplicates found
- deleted ALL versions of every item from the list (except current), ensured they were completely removed by deleting from both site and site collection recycle bins
- Using the SP Powershell console, grabbed all list items and exported all of the "Title" type fields (Item object Title, LinkTitle, LinkTitleNoMenu, etc) to a csv and ran that through excel duplicate checking as well.
Unless there's some rediculous hidden field value that MS expects anyone capable of attempting to enforce unique values on a list (which is simple enough for anyone to figure out - if it doesn't throw an error), then I've exhausted anything I can think
of that might cause the list to report duplicate values for that field.
While I wait to see if someone else has an idea, I'm also going to see what happens if I wipe the Crawl Index and start it from scratch.
- JonFirst, I create index for a column in list settings, it works fine no matter duplicate value exists or not;
then I set enforce unique values in the field, after click OK, I get duplicate values error message.
With SQL Server profiler, I find the call to proc_CheckIfExistingFieldHasDuplicateValues and the parameters. After reviewing this stored procedure in content database,
I create the following script in SQL Server management studio:
declare @siteid
uniqueidentifier
declare @webid
uniqueidentifier
declare @listid
uniqueidentifier
declare @fieldid
uniqueidentifier
set @siteid='F7C40DC9-E5D3-42D7-BE60-09B94FD67BEF'
set @webid='17F02240-CE04-4487-B961-0482B30DDA84'
set @listid='B349AF8D-7238-419D-B6C4-D88194A57EA7'
set @fieldid='195A78AC-FC52-4212-A72B-D03144DC1E24'
SELECT
* FROM TVF_UserData_List(@ListId)
AS U1 INNER
MERGE JOIN
NameValuePair_Latin1_General_CI_AS
AS NVP1 WITH (INDEX=NameValuePair_Latin1_General_CI_AS_MatchUserData)
ON NVP1.ListId
= @ListId AND NVP1.ItemId
= U1.tp_Id
AND ((NVP1.Level
= 1 AND U1.tp_DraftOwnerId
IS NULL)
OR NVP1.Level
= 2)
AND NOT((DATALENGTH(ISNULL(NVP1.Value,
= 0)) AND U1.tp_Level
= NVP1.Level
AND U1.tp_IsCurrentVersion
= CONVERT(bit, 1)
AND U1.tp_CalculatedVersion
= 0 AND U1.tp_RowOrdinal
= 0 INNER
MERGE JOIN
NameValuePair_Latin1_General_CI_AS
AS NVP2 WITH (INDEX=NameValuePair_Latin1_General_CI_AS_CI)
ON NVP2.SiteId
= @SiteId AND NVP2.ListId
= @ListId AND NVP2.FieldId
= @FieldId AND NVP2.Value
= NVP1.Value
AND NVP2.ItemId <> NVP1.ItemId
CROSS APPLY TVF_UserData_ListItemLevelRow(NVP2.ListId, NVP2.ItemId,
NVP2.Level, 0)
AS U2 WHERE ((NVP2.Level
= 1 AND U2.tp_DraftOwnerId
IS NULL)
OR NVP2.Level
= 2)
AND NOT((DATALENGTH(ISNULL(NVP2.Value,
= 0))
I can find the duplicate list items based on the result returned by the query above.
Note that you need to change the parameter values accordingly, and change the name of NameValuePair_Latin1_General1_CI_AS table based on the last parameter of the
proc_CheckIfExistingFieldHasDuplicateValues stored procedure. You can review the code of this stored procedure by yourself.
Note that direct operation on the content database in production environment is not supported, please do all these in test environment. -
Need help-SQL with result format suppressing duplicate values
I am trying to write a SQL which would select data from the below tables(in reality i have many other tables also) but I wanted to know how do i get the data in the format given below.
The scenario is :-A training_plan can N no. of OBJECTIVES and EACH objective has N no.of activities
Insert into TEST_TRAINING_PLAN
(TPLAN_ID, TPLAN_NAME, TPLAN_DESC, T_PERSON_ID
Values
('111', 'test_name', 'test_name_desc', '****')
Objectives table:-
Insert into TEST_TRAINING_OBJECTIVE
(T_OBJECTIVE_ID, T_OBJECTIVE_NAME,T_owner)
Values
('10', 'objective1', '1862188559')
Objective and Training Plan relationship table where TPLAN_ID is the foreign key.
Insert into TEST_TP_OBJECTIVE
(TPLAN_TOBJ_ID, TPLAN_ID, T_OBJECTIVE_ID,
REQUIRED_CREDITS)
Values
('1', '111', '10',5)
Objective and Activity relationship table where T_OBJECTIVE_ID is the foreign key from the TEST_TRAINING_OBJECTIVE table.
Insert into TEST_TRAIN_OBJ_ACTIVITY
(TOBJ_TRAIN_ACTIVITY, T_OBJECTIVE_ID, ACTIVITY_ID, IS_REQUIRED, STATUS,
ACTIVITY_TYPE, ITEM_ORDER, IS_PREFERRED)
Values
('1000', '10', 'selfstudy event', SS1, NULL,
'Event', 0, 0);
Insert into TEST_TRAIN_OBJ_ACTIVITY
(TOBJ_TRAIN_ACTIVITY, T_OBJECTIVE_ID, ACTIVITY_ID, IS_REQUIRED, STATUS,
ACTIVITY_TYPE, ITEM_ORDER, IS_PREFERRED)
Values
('1001', '10', 'SQLcourse', 1, NULL,
'Course', 1, 0);
Insert into TEST_TRAIN_OBJ_ACTIVITY
(TOBJ_TRAIN_ACTIVITY, T_OBJECTIVE_ID, ACTIVITY_ID, IS_REQUIRED, STATUS,
ACTIVITY_TYPE, ITEM_ORDER, IS_PREFERRED)
Values
('1002', '10', 'testSQL', 1, NULL,
'test', 2, 0);
COMMIT;
firstname emplid Tplan name Number of activities/credits completed(for TP) Objective Name Number of required activities/Credits (for objective) Number of activities/credits completed(for objective) activity name activity completion status
U1 U1 TP1 5
OBJ1 4 3 C1 PASSED
C2 PASSED
C3 WAIVED
T1 ENROLLED
T2 ENROLLED
OBJ2 3 2
S1 ENROLLED
S2 PASSED
T3 WAIVED
U1 U1 TP2 C4 INPROGRESS
50 OBJ11 50 30 C11 PASSED
**The second row where we have another training_plan record and accordingly all objectivesand their objective.**similarly ,i need to display many Training_plan records in such tabular format.Please help with the SQL query to select and display data in the above format
If you want to suppress duplicate values in some of your results columns
I am using toad 9.1 using Oracle 10g version 2Hi,
You can use the BREAK command to suppress duplicate values.
http://download.oracle.com/docs/cd/B19306_01/server.102/b14357/ch12009.htm#SQPUG030
(scroll down for an example)
It's a 'SQL*Plus-ism', not sure if TOAD's capable to handle it.
Simple example:
HR%xe> break on department_name
HR%xe> select l.department_name
2 , e.last_name
3 , e.first_name
4 from departments l
5 , employees e
6 where e.department_id = l.department_id;
DEPARTMENT_NAME LAST_NAME FIRST_NAME
Executive King Steven
Kochhar Neena
De Haan Lex
IT Hunold Alexander
Ernst Bruce
Austin David
Pataballa Valli
Lorentz Diana
Finance Greenberg Nancy
Faviet Daniel
Chen John
Sciarra Ismael
Urman Jose Manuel
Popp Luis
Purchasing Raphaely Den
Khoo Alexander
Baida Shelli
Tobias Sigal
Himuro Guy
Colmenares Karen
Shipping Weiss Matthew
Fripp Adam
Kaufling Payam
Vollman Shanta
Mourgos Kevin
Nayer Julia
Mikkilineni Irene
Landry James
Public Relations Baer Hermann
Accounting Higgins Shelley
Gietz William
106 rijen zijn geselecteerd. -
Query produces duplicate values in successive rows. Can I null them out?
I've had very good success (Thanks Andy) in getting detailed responses to my posted questions, and I'm wondering whether there is a way in a report region join query that produces successive rows with duplicate values that I can suppress(replace) the print of the duplicate values in those rows. In case I've managed to twist the question into an unintelligible mess (One of my specialties), let me provide an example:
We're trying to list the undergraduate institutions that an applicant has attended, and display information about dates of attendence, gpa, and major(s)/minor(s) taken. The rub is that there can be multiple major(s)/minor(s) for a given undergraduate institution, so the following is produced by the query:
University of Hard Knox 01/02 01/06 4.00 Knitting
University of Hard Knox 01/02 01/06 4.00 Cloth Repair
Advanced University 02/06 01/08 3.75 Clothing Design
Really Advanced U 02/08 01/09 4.00 Sports Clothing
Really Advanced U 02/08 01/09 4.00 Tennis Shoe Burlap
I want it to look like this:
University of Hard Knox 01/02 01/06 4.00 Knitting
Cloth Repair
Advanced University 02/06 01/08 3.75 Clothing Design
Really Advanced U 02/08 01/09 4.00 Sports Clothing
Tennis Shoe Burlap
* (edit) Please note that the cloth repair and tennis shoe repair rows would be correctly positioned in a table, but unfortunately got space suppresed here for some reason. *
Under Andy's tuteage, I'd say the answer is probably javascript looping through the DOM looking for the innerHTML of specific TDs in the table, but I'd like to confirm that, or, does Apex provide a checkbox that I can check that will produce the same results? Thanks in advance guys, and sorry for all the questions. We've been tasked to use Apex for our next project and to learn it by using it, since the training budget is non-existant this year. I love unfunded mandates ;)
Phil
Edited by: Phil McDermott on Aug 13, 2009 9:34 AMHi Phil,
Javascript is useful, as is the column break functionality within Report Attributes (which would be my first choice if poss).
If you need to go past 3 columns, I would suggest doing something in the SQL statement itself. This will mean that the sorting would probably having to be controlled, but it is doable.
Here's a fairly old thread on the subject: Re: Grouping on reports (not interactive) - with an example here: [http://htmldb.oracle.com/pls/otn/f?p=33642:112] (I've even used a custom template for the report, but you don't need to go that far!)
This uses the LAG functionality within SQL to compare the values on one row to the values on the preceeding row - being able to compare these values allows you to determine which ones to display or hide.
Andy -
SSAS report action to pass multi-value list of dimention key values to a SSRS report parameter
This was originally posted on StackOverflow and suggested I try here as well.
I want to create a report action in an SSAS OLAP cube that generates a list of formatted values to pass into an SSRS report parameter that accepts a multi-valued parameter list. This would be applied at the
cell level in the SSAS action. I have found a solution that gets me most of the way:
How to Pass Multiple Values from an SSAS Report Drill Through Action to an SSRS Multi-Value Parameter, but not quite. The action does appear in Excel and works
if I run the action from a cell that is at or below the dimension attribute I am generating the list for, in this case,
Account Key.
Below is a link to a screen capture (unable to embed it due to lack of reputation) showing the action and dimension structure in Excel. The action works as long as I run it at the
Account Key level or below. I want to be able to run it at higher levels, such as
Account Major and still have it generate all then related Account Key values for the SSRS report parameter. Running it at the higher
Account Major level does not trigger the report to run.
Excel Action Screen Shot:
http://i.stack.imgur.com/QCGSp.png
Below is the MDX I am using to generate the value for the report parameter:
UrlEscapeFragment(
GENERATE(
DESCENDANTS(
[Account].[Account Key].CurrentMember,
[Account].[Account Key].[Account Key]
[Account].[Account Key].CURRENTMEMBER.Name,
"&rp:Account="
I am hoping that I can somehow modify the MDX above to make it return all the
Account Keys for any attribute of the Account dimension when ran from any measure cell, not just when ran at self and children of
Account Key in the pivot table.
Also, if it helps, I can execute the following MDX query on the cube and get the results I am looking for.
WITH MEMBER [Measures].[Account Key List] as
GENERATE(
DESCENDANTS([Account].[Account].CurrentMember, [Account].[Account].[Account]),
[Account].[Account].CURRENTMEMBER.NAME,
"&rp:Account=")
SELECT {[Measures].[Account Key List]} on 0,
([Account].[Account Company Number].[Account Company Number],[Account].[Account Major].[Account Major]
) on 1
FROM [Company 10 Action Demo]
Below are partial results:
10.116&rp:Account=10.116.010
10.117&rp:Account=10.117.010&rp:Account=10.117.020
10.120&rp:Account=10.120.005&rp:Account=10.120.006&rp:Account=10.120.010&rp:Account=10.120.020&rp:Account=10.120.030&rp:Account=10.120.040&rp:Account=10.120.050&rp:Account=10.120.060&rp:Account=10.120.380&rp:Account=10.120.999
10.123
Questions
Any ideas what I might need to do to get Account Key to be returned for any attribute of the
Account dimension?
Would I possibly have to alter my Account dimension in the cube to get this to work?
Thanks in advance.
Edit 1 - Adventure Works Cube Version
I was unable to get the suggested answer with the "Exists" function to work. To better demonstrate this issue, I have recreated it using the Adventure Works Cube.
I will focus on the Customer dimension, specifically the Customer and
Education attributes. I created a report action called Test Report Action. Below is the XML created for it in the cube.
<Action xsi:type="ReportAction" dwd:design-time-name="f35ad5ee-5167-4fb8-a0e0-0a74cc6e81c6">
<ID>Report Action 1</ID>
<Name>Test Report Action</Name>
<TargetType>Cells</TargetType>
<Target></Target>
<Type>Report</Type>
<ReportServer>SQLSERVER</ReportServer>
<Path>ReportServer?/Test Report</Path>
<ReportParameters>
<ReportParameter>
<Name>Test Customer Existing</Name>
<Value>UrlEscapeFragment(
GENERATE(
EXISTING DESCENDANTS(
[Customer].[Customer].CurrentMember,
[Customer].[Customer].[Customer]
[Customer].[Customer].CURRENTMEMBER.Name,
"&rp:Customer="
)</Value>
</ReportParameter>
</ReportParameters>
<ReportFormatParameters>
<ReportFormatParameter>
<Name>rs:Command</Name>
<Value>Render</Value>
</ReportFormatParameter>
<ReportFormatParameter>
<Name>rs:Renderer</Name>
<Value>HTML5</Value>
</ReportFormatParameter>
</ReportFormatParameters>
</Action>
Below are the steps to re-create the issue.
Connect to the cube in Excel
Add dimension Customer -> More Fields -> Customer
Add measure Internet Sales -> Internet Sales Amount
Right-click Internet Sales Amount cell, select "Additional Actions" -> "Test Report Action" and see customer values created for URL
When the action is ran at this point with Customer, I see the values created in the URL shown message box (since there is no SSRS report server at location specified).
Now the part I'm unable to resolve
Remove the Customer dimension and add Customer -> Demographic -> Education
Right-click Internet Sales Amount cell, select "Additional Actions" -> "Test Report Action"
Nothing happens. If I ran the action on the cell next to "Bachelors", I would want it to build up all the list of all the "Customers" that make up the "Bachelors" in the
Customer dimension as part of the report parameter. If no attributes where used in the cube from the
Customer dimension for that cell, then I would like it to return "All Customers", or something similar to show that all customers are included in the aggregations.
I am not too MDX savvy, thus far. I think I need to somehow join the
Customers to Internet Sales Amount in the Generate function portion. I have tried several different combinations of the
Customer dimension and Internet Sales Amount, along with various functions to see if I could get this to work with no success. I am hoping that someone more knowledgeable the me will have a solution. If you need more details,
please ask and I will provide them.Simon,
Thanks for you help with this. This morning I found a workaround. Below describes what that is.
What I ended up doing was getting a list of values from a degenerate dimension that I could use to pass to SSRS to get a list of transactions for a report. Below is how I did this, in relation to the Adventure Works cube using the degenerate dimension
Internet Order Details.
WITH MEMBER [Measures].[Order Param List] AS
GENERATE(
EXISTS([Internet Sales Order Details].[Sales Order Number].[Sales Order Number].Members, ,
"Internet Sales"),
[Internet Sales Order Details].[Sales Order Number].CurrentMember.Name,
"&rp:OrderNum=")
SELECT {[Measures].[Order Param List], [Measures].[Internet Sales Amount]} ON 0
,([Date].[Calendar].[Date]) ON 1
FROM [Adventure Works]
This will get a list of Sales Order Number in a text string, separated by "&rp:OrderNum=" for each measure of
Internet Sales. This would allow me to create an SSRS report to bring back detail information for each
Sales Order Number. Below are some sample results.
May 16, 2007 SO50493&rp:OrderNum=SO50494&rp:OrderNum=SO50495&rp:OrderNum=SO50496&rp:OrderNum=SO50497&rp:OrderNum=SO50498&rp:OrderNum=SO50499&rp:OrderNum=SO50500 $12,157.80
May 17, 2007 SO50501&rp:OrderNum=SO50502&rp:OrderNum=SO50503&rp:OrderNum=SO50504&rp:OrderNum=SO50505&rp:OrderNum=SO50506&rp:OrderNum=SO50507&rp:OrderNum=SO50508 $13,231.62
May 18, 2007 SO50509&rp:OrderNum=SO50510 $4,624.91
With this, I can then create a Report Action in SSRS with a Parameter Value of
UrlEscapeFragment(
GENERATE(
EXISTS([Internet Sales Order Details].[Sales Order Number].[Sales Order Number].Members, ,
"Internet Sales"),
[Internet Sales Order Details].[Sales Order Number].CurrentMember.Name,
"&rp:OrderNum=")
The way I was going about it before was flawed, as I was trying to get a list of the granular values from each dimension used to build the measure value and pass each one of those as separate parameters. I just needed to set something unique for each fact
measure transaction that represents the value and uses that in a query parameter for the SSRS report. -
Greetings Everyone,
I am getting the follow up errors: "This field contains duplicate values. Remove all duplicate values and try the operation again."
when I tried to make the field "Claim Number" from the list in site collection library. See the screen below:
1- I selected on the "List" and I clicked on the list name
"Claim Tracking Report"
2- After I clicked on the list name then I went to the ribbon and selected list setting to choose Enforce Unique for the Field Column
"Claim Number"
3- Then I went down and selected
"Yes" to Enforced the Unique for the Field Column "Claim Number".
4- Then after I clicked "Yes" I got the error
"Sorry, something went wrong. This field contains duplicate values. Remove all duplicate values and try the operation again." But I don't have any duplicates values Items, because I had them removed before I tried
to Enforce the field column values to Unique. Can someone help or provide me a suggestions on how I can solve this issue please. Thank you
FYI: I am using a Nintex WorkflowHope this is a list, how many total items are there?
Please try to open this list as access(link in IE) and run this query in access
SELECT Claim.[Claim Number], Count(*) AS Expr1
FROM Claim
GROUP BY Claim.[Claim Number]
HAVING (((Count(*))>1));
Hope it will show something! if this does not show you dups then better to create a separate list and migrate items after configuring unique column.
Please 'propose as answer' if it helped you, also 'vote helpful' if you like this reply. -
I'm very new to Forms..
I've a table VIK_SAM with two columns : Id and Name
I'm creating a layout with two text fields(to enter Id and Name) and a submit button.
When I run the form, enter the values and click on submit button, duplicate values are inserted in the the table. like below
Id Name
20 abc
20 abc
How can I make sure only one record is being inserted. This is the code I had written in the WHEN BUTTON PRESSED Trigger..
begin
insert into vik_sam (id, name)
values (:vik_sam.id, :vik_sam.name);
commit;
end;
P.S.. This is not an assignment. I'm done with my current project and I'm on bench right now. So trying to learn this tool. :)The fact that you're doing a sql insert suggests to me that your block is not based on a database table. If that is true then try the following:
begin
insert into vik_sam (id, name)
values (:vik_sam.id, :vik_sam.name);
commit;
exception
when dup_val_on_index then
message('A record already exists with that Id.');
message('A record already exists with that Id.');
raise form_trigger_failure;
end;Alternatively, you could use a merge command to update the name if the ID already exists. -
Retrieving value of command-line parameters
Hi experts!
Is there any whay to get value of command line parameter supplied with Reports runtime module or by RUN_PRODUCT call?
I mean parameters like BATCH, PARAMFORM etc which are not listed among report system parameters.
Is it possible somehow to access them in report's PL/SQL?
Regards,
AlexHi Alex,
Not an expert so only a 1/2 solution : for each keyword used define an user parameter with the same value and transmit it on the cmd line. You can see now the values in report as normal parameters ( you can't change the keywords values).
Have a good WE
Daniel -
Duplicate Values in an Internal Table
Hi,
Is it possible to delete records having Duplicate Values in a field, in an Internal Table, but in the situation when the Internal Table is NOT sorted on that field ?
Regards,
Pankaj.Hi Pankaj,
i think you have to create a copy of your itab and collect.
try this:
REPORT ZGRO_TEST.
DATA: BEGIN OF ITAB OCCURS 0,
MATNR LIKE MARA-MATNR,
VBELN LIKE VBAK-VBELN,
END OF ITAB.
DATA: BEGIN OF ITAB1 OCCURS 0,
MATNR LIKE MARA-MATNR,
VBELN LIKE VBAK-VBELN,
END OF ITAB1.
START-OF-SELECTION.
itab-matnr = '000000000000000111'. itab-vbeln = '0000000011'. append itab.
itab-matnr = '000000000000000113'. itab-vbeln = '0000000013'. append itab.
itab-matnr = '000000000000000111'. itab-vbeln = '0000000011'. append itab.
itab-matnr = '000000000000000112'. itab-vbeln = '0000000012'. append itab.
itab-matnr = '000000000000000111'. itab-vbeln = '0000000011'. append itab.
itab-matnr = '000000000000000112'. itab-vbeln = '0000000012'. append itab.
itab-matnr = '000000000000000113'. itab-vbeln = '0000000013'. append itab.
loop at itab.
itab1 = itab.
collect itab1.
endloop.
loop at itab.
write: / itab-matnr, itab-vbeln.
endloop.
write: / sy-uline.
loop at itab1.
write: / itab1-matnr, itab1-vbeln.
endloop.
END-OF-SELECTION.
if you whant it back in itab. refrash itab and copy itab1 to itab.
Hope it helps.
Regards, Dieter -
Duplicate value in export file
Hi,
I have a sql report where I have implemented download to excel using the print attribute. When I export the report into Excel, there are few columns whose values getting duplicated in the spreadsheet where as those column values are blank in the report.
for example.
Query:
select col1 col2 col3 col4 from table1;
The report displays the correct value for col1 col2 col3 col4 but in the export file value for col1, col2, col3 are correct but col4 is picking up the value of col3.
Any help? Thanks.
--ManishHi Scott,
Could you please have a look at it.
http://apex.oracle.com/pls/otn/f?p=47427:12
When you will click download_excel at the bottom of the page, the export file will show you the duplicate values for the column [G-L].
Thanks again for your help.
--Manish
Message was edited by:
Manish Jha -
Duplicate Value Restriction in Value Mapping Replication
Hello Everyone,
I was working on Value mapping replication interface which was working fine. But the value mapping replication was allowing duplicate values which are already existing. We are using this value mapping in other interfaces. But because of multiple entries exists for the same values the value mapping was giving blank value as a response. It was not giving any value even though the values are exists in value mapping table. can any one let me know how to restrict duplicate entries in value mapping replication.
Regards,
RajuHi Arun,
could you provide the whole command sentence for the JS to set the filter value? I am not sure what value to specify for 'All'. It is actually 'no filtering', I understand. But what is this value to set for 'no filtering'? Must I use both dropdown.value and dropdown.text or could I just use dropdown.value?
So, I cannot disable 'All' as I need to use it specifically as 'filter' value.
Pls advise.
Message was edited by: alfonso
Maybe you are looking for
-
Mapping Problem: only constants are mapped the rest is missing
Hi Community, I have a really strange problem. I mapped a message type and an external definition (a modified IDoc) in the repository. If I use the test function of the message mapping everything is fine. All values and constants are mapped correctly
-
Where should I save the playlists file
In what specific file on my computer should i save my iTunes personal playlists files
-
my iphone 4 8GB (iOS5.0.1) is know 2 weeks old and i noted: it gets very hot if i recording a video or charging it. shortly after i recorded a video i couldn't hear anything out of the speaker and couldn't change the volume. after i have waited 15
-
Do not order phone online big scam
Ordered a phone online Fedex delivered a empty box that was clearly tampered with, neither fedex or Verizon want to help. Very disappointed after being with Verizon over 10 years. Now I'm out 400 dollars and not sure what to do. Seems like a big scam
-
Percentage (%) in report
Hi SDNs Here iam doing one report. My client has been maintaining condition type in % he entered manuvally in the sales oredr and that would be copied in to billing that is commission condition type . When he execued the report he wants shown percent