Abap logic not fetching multiple rows from master data table
Hi
I just noticed that my logic is fetching only 1 row from master data table.
ProdHier table
PRODHIERACHY Level
1000 1
1000011000 2
10000110003333 3
10000110004444 3
'10000110005555 3*
logic only fetches one row of level 3, I would like to fetch all level 3 rows.
DATA: ITAB type table of /BI0/PPROD_HIER,
wa like line of ITAB.
Select * from /BI0/PPROD_HIER INTO wa where /BIC/ZPRODHTAS = 3.
IF wa-PROD_HIER(10) = SOURCE_FIELDS-PRODH2.
RESULT = wa-PROD_HIER.
ELSEIF wa-PROD_HIER(5) = SOURCE_FIELDS-PRODH1.
RESULT = wa-PROD_HIER.
ENDIF.
ENDSELECT.
thanks
Hi,,
I have implemented the logic in end routine and it still reads only the first row.
I am loading only PRODH1 and PROD2 but now I want to get all values of PRODH3 from the master data table.
The first 5 values are PRODH1 and first 10 values belongs to PRODH2.
Whenever PRODH2 = 1000011000 in source I should get the following values
10000110001110
10000110001120
10000110001130
I have multiple rows of 1000011000 so my result should be
1000011000 10000110001110
1000011000 10000110001120
1000011000 10000110001130
DATA: ITAB type table of /BI0/PPROD_HIER,
wa like line of ITAB.
data rp type _ty_s_TG_1.
Select * from /BI0/PPROD_HIER INTO table itab where /BIC/ZPRODHTAS = 3.
LOOP AT RESULT_PACKAGE INTO rp.
read table itab into wa with key PROD_HIER(5) = rp-PRODH1.
IF sy-subrc EQ 0.
rp-PRODH3 = wa-PROD_HIER.
ELSE.
read table itab into wa with key PROD_HIER(10) = rp-PRODH2.
IF sy-subrc EQ 0.
rp-PRODH3 = wa-PROD_HIER.
ENDIF.
ENDIF.
MODIFY RESULT_PACKAGE FROM rp.
ENDLOOP.
Edited by: Bhat Vaidya on Sep 10, 2010 11:27 AM
Edited by: Bhat Vaidya on Sep 10, 2010 11:37 AM
Similar Messages
-
Abap code not working - deleting based on master data table information
Hi,
I wrote a piece of code earlier which is working and during test we found out that it will be hard for the support guys to maintain because it was hard coded and there is possibility that users will include more code nums in the future
sample code
DELETE it_source WHERE /M/SOURCE EQ 'USA' AND
/M/CODENUM NE '0999' AND
/MCODENUM NE '0888' AND.
Now I created a new InfoObject master data so that the support people can maintain the source and code number manually.
master data table - the codenum is the key.
XCODENUM XSOURCE
0999 IND01
0888 IND01
now I wrote this routine all the data gets deleted.
tables /M/PGICTABLE.
Data tab like /M/PGICTABLE occurs 0 with header line.
Select * from /M/PGICTABLE into table tab where objvers = 'A'.
if sy-subrc = 0.
LOOP at tab.
DELETE it_source WHERE /M/SOURCE EQ tab-XSOURCE AND /M/CODENUM NE tab-XCODENUM.
ENDLOOP.
Endif.
But when I chage the sign to EQ, I get opposite values , Not what I require.
DELETE it_source WHERE /M/SOURCE EQ tab-XSOURCE AND /M/CODENUM EQ tab-XCODENUM.
Cube table that I want to extract from
/M/SOURCE /M/CODENUM
IND01 0999
IND01 0888
IND01 0555
IND01 0444
FRF01 0111
I want to only the rows where the /M/CODENUM = 0999 and 0888 and i would also need FRF101
and the rows in bold should be deleted.
thanks
Edited by: Bhat Vaidya on Jun 17, 2010 12:38 PMIt's obvious why it deletes all the records. Debug & get your answer i wont spoon feed
Anyways on to achieve your requirement try this code:
DATA:
r_srce TYPE RANGE OF char5, "Range Table for Source
s_srce LIKE LINE OF r_srce,
r_code TYPE RANGE OF numc04,"Range table for Code
s_code LIKE LINE OF r_code.
s_srce-sign = s_code-sign = 'I'.
s_srce-option = s_code-option = 'EQ'.
* Populate the range tables using /M/PGICTABLE
LOOP AT itab INTO wa.
s_code-low = wa1-code.
s_srce-low = wa1-srce.
APPEND: s_code TO r_code,
s_srce TO r_srce.
ENDLOOP.
DELETE ADJACENT DUPLICATES FROM:
r_code COMPARING ALL FIELDS,
r_srce COMPARING ALL FIELDS.
* Delete from Cube
DELETE it_source WHERE srce IN r_srce AND code IN r_code. -
Extract Multiple Rows from a Single Table into a Single Row in a New Table
I have a table in a database that contains contact data like name, address, phone number, etc.
The folks who designed the database and wrote the application wrote it so that all contact records are placed in that table, regardless of contact type. In fact, the contacts table does not even have a column for "type" even though there are many
different types of contacts present in that table.
I am trying to write a mail merge style report in SRSS, that gets sent to a specific type of contact, based on criteria provided that must be obtained from another table, and that data is then used to get back to a specific set of contacts from the contacts
table.
The attached file directly below describes my problem and all related information in an extremely detailed way.
SRSSMailMergeIssue.pdf
Unless there is a way to make a SRSS Tablix point to two different data sets in SRSS, it looks like I have to combine multiple rows from the same table into a new table.
If anyone can review the details in the attached pdf file and possibly point me in the direction I need to run to solve this probelm, I would greatly appreciate it.
I also included a document (below) that shows the tables I reference in the probelm description.
dbtables.pdfI found a solution.... and posted it below
select
dk.ucm_docketnumber [UCM DocketNumber],
dk.ucm_docketid [UCM DocketID],
vc.FirstName [Victim FirstName],
vc.MiddleName [Victim MiddleName],
vc.LastName [Victim LastName],
vc.Suffix [Victim Suffix],
vc.Address1_Line1 [Victim AddressLine1],
vc.Address1_Line2 [Victim AddressLine2],
vc.Address1_Line3 [Victim AddressLine3],
vc.Address1_City [Victim City],
vc.Address1_StateOrProvince [Victim StateProvince],
vc.Address1_PostalCode [Victim Postalcode],
oc.FirstName [Offender FirstName],
oc.MiddleName [Offender MiddleName],
oc.LastName [Offender LastName],
oc.Suffix [Offender Suffix],
oc.Address1_Line1 [Offender AddressLine1],
oc.Address1_Line2 [Offender AddressLine2],
oc.Address1_Line3 [Offender AddressLine3],
oc.Address1_City [Offender City],
oc.Address1_StateOrProvince [Offender StateProvince],
oc.Address1_PostalCode [Offender Postalcode],
pc.FirstName [Arresting Officer FirstName],
pc.MiddleName [Arresting Officer MiddleName],
pc.LastName [Arresting Officer LastName],
pc.Address1_Line1 [Arresting Officer AddressLine1],
pc.Address1_Line2 [Arresting Officer AddressLine2],
pc.Address1_Line3 [Arresting Officer AddressLine3],
pc.Address1_City [Arresting Officer City],
pc.Address1_StateOrProvince [Arresting Officer StateProvince],
pc.Address1_PostalCode [Arresting Officer Postalcode]
FROM ucm_docket dk
left outer join ucm_victim v on dk.ucm_docketid = v.ucm_docketnumber
left outer join contact vc on vc.contactid = v.ucm_victimlookup
left outer join ucm_offender o on o.ucm_offenderid = dk.ucm_offenderlookup
left outer join contact oc on oc.contactid = o.ucm_individualid
left outer join contact pc on pc.contactid = dk.ucm_ArrestingOfficerLookup
WHERE (dk.ucm_docketnumber = @DocketNUM) -
Web report data provider change from Master data table to InfoCube
hi Experts,
I have created one report on top of multiprovider but in the selection screen when i check the values for a variable I came to know that data is coming from master data table and not from data provider(InfoCube).Can any one help to change the data selection from master data table to data provider(InfoCube) and i am sure that there is no ODS involved in the multiprovider.
Thanks in advance
With Regards,
BalaHello,
If u are using Analyser then just put a Analysis Grid on the output of the query(should cover all the rows and column) , click on the grid and put the dataprovider. and do auto fit.
Rohit -
Multiprovider not taking info from master data table?
Hi all,
i've a problem with a multiprovider and some navigational attributes of zmaterial.
There are several infocubes in the multiprovider and they all have zmaterial, the problem is that the data from one of these cubes is taking the values of some navigational attribute from the cube itself, not from the master data table of zmaterial even if i changed the assignment from the multiprovider.
Is there any option i must check/look to get this thing work?
If you need any other info just let me know.
Thank you.Hi,
It seems the identificaiton are still incorrect.
Just try to put the identification for those characteristics from the navigational attribute option in the multiprovider and not from the infoobject present in the cube.
So for ZMaterial_A it should be identified with ZMaterial_A in the multicube from the respective cubes.
Thanks
Ajeet -
Navigatiomnal attribute is not possible to delete from master data?
WHen I tried to delete the navagational attribute I am getting an erro like this.
Characteristic Z5xyz: Master data has to be activated before conversion
Message no. R7067
Diagnosis
The master data for characteristic Z5xyz has to be converted, because an attribute has been deleted, or the time-dependency of an attribute has been changed. This process is possible, only if the master data for characteristic Z5xyz is active. The master data table /BIC/PZ5xyz contains only new or modified records, that have not yet been activated.
System Response
Characteristics Z5xyz cannot be activated.
Procedure
Activate the master data for characteristic Z5xyz , before you activate the characteristic itself.
Can any one help me to resovlet his.
points will be definitely assigned.
Thanks,.
VasuHi Vasu,
You are tying to delete a table filed when the table contains data. For this you need to adjust the database table.
But instead of doing all this you may follow a simpler method.
Before deleting that Characteristics you need to delete the Masterdata first. Then delete the Characteristics from the attribute list and activate the Masterdata Object. Now reload the masterdata.
Regards,
Pratap Sone -
Currency translation - not picking up currencies from master data
Hi,
We have a currency translation defined for a key figure. We've defined a variable for users to select target currency. 0currency is set to pick up from master data, but the input help on the variable is only showing currencies from infoprovider. I debugged the query and it is trying to get the currencies from the cube. Any setting that I do or update?
We're using BW 7.3 SP10 on HANA.
SonniHI
Once check in the BEx tab of that IO, there select the f4 option.
Regards,
Sunil. -
Logic to fetch multiple records from BKPF, SRGBTBREL and SOOD
Hi All
Need help in developing a login for a report.
We are trying to display records of a/c documents which have an associated note with them. This involves 4 categories.
1) My Document, I attached the note.
2) My Document, someone else attached the note.
3) No note attached.
4) All.
The logic desired is as below:
1) BKPF-BUKRS + BKPF-BELNR + BKPF-GJAHR = SRGBTBREL-INSTID_A. (SRGBTBREL can have multiple records for this combination if multiple notes attached)
2) a) SOOD-OBJTY = SRGBTBREL-INSTID_B+17(3).
b) SOOD-OBJYR = SRGBTBREL-INSTID_B+20(2).
c) SOOD-OBJNO = SRGBTBREL-INSTID_B+22(12).
Unique combination.
I have fetched the details from the three database tables but finding it challenging to put it across in one output internal table. It doesnu2019t cover the scenario where multiple notes are attached to the document (One can be from the same person who created the document and another ones can be from different person or both from the different people).
Thanks in advance,
HarshCode Snippet Part 2.
* Approved Document.
IF rb_app = 'X'.
CLEAR wa_sood.
* READ TABLE gt_sood INTO wa_sood WITH KEY objtp = lv_objtp
* objyr = lv_objyr
* objno = lv_objno.
LOOP AT gt_sood INTO wa_sood WHERE objtp = lv_objtp
and objyr = lv_objyr
and objno = lv_objno.
* IF sy-subrc = 0.
IF wa_bkpf-usnam <> wa_sood-cronam.
* Company Code.
wa_output-bukrs = wa_bkpf-bukrs.
* A/c Document No.
wa_output-belnr = wa_bkpf-belnr.
* Fiscal Year.
wa_output-gjahr = wa_bkpf-gjahr.
* Document Type.
wa_output-blart = wa_bkpf-blart.
* Document Date.
wa_output-budat = wa_bkpf-budat.
* Day On Which Accounting Document Was Entered.
wa_output-cpudt = wa_bkpf-cpudt.
* User name.
wa_output-usnam = wa_bkpf-usnam.
* Reverse Document Number.
wa_output-stblg = wa_bkpf-stblg.
* Transaction Code.
wa_output-tcode = wa_bkpf-tcode.
* Short description of contents.
wa_output-objdes = wa_sood-objdes.
* Creator Name.
wa_output-cronam = wa_sood-cronam.
* Date created.
wa_output-crdat = wa_sood-crdat.
* Time created.
wa_output-crtim = wa_sood-crtim.
* Status.
WRITE icon_green_light TO wa_output-light.
APPEND wa_output TO gt_output.
* CLEAR: wa_output,
* wa_sood.
* ENDIF.
ENDIF.
ENDLOOP.
ENDIF.
* All Documents.
IF rb_all = 'X'.
* Company Code.
wa_output-bukrs = wa_bkpf-bukrs.
* A/c Document No.
wa_output-belnr = wa_bkpf-belnr.
* Fiscal Year.
wa_output-gjahr = wa_bkpf-gjahr.
* Document Type.
wa_output-blart = wa_bkpf-blart.
* Document Date.
wa_output-budat = wa_bkpf-budat.
* Day On Which Accounting Document Was Entered.
wa_output-cpudt = wa_bkpf-cpudt.
* User name.
wa_output-usnam = wa_bkpf-usnam.
* Reverse Document Number.
wa_output-stblg = wa_bkpf-stblg.
* Transaction Code.
wa_output-tcode = wa_bkpf-tcode.
CLEAR wa_sood.
* READ TABLE gt_sood INTO wa_sood WITH KEY objtp = lv_objtp
* objyr = lv_objyr
* objno = lv_objno.
LOOP AT gt_sood INTO wa_sood WHERE objtp = lv_objtp
and objyr = lv_objyr
and objno = lv_objno.
* ELSE.
IF wa_bkpf-usnam <> wa_sood-cronam.
* Status.
WRITE icon_green_light TO wa_output-light.
* Short description of contents.
wa_output-objdes = wa_sood-objdes.
* Creator Name.
wa_output-cronam = wa_sood-cronam.
* Date created.
wa_output-crdat = wa_sood-crdat.
* Time created.
wa_output-crtim = wa_sood-crtim.
ELSE.
* Status.
WRITE icon_yellow_light TO wa_output-light.
* Short description of contents.
wa_output-objdes = wa_sood-objdes.
* Creator Name.
wa_output-cronam = wa_sood-cronam.
* Date created.
wa_output-crdat = wa_sood-crdat.
* Time created.
wa_output-crtim = wa_sood-crtim.
ENDIF.
* ENDIF.
ENDLOOP.
IF sy-subrc <> 0.
WRITE icon_red_light TO wa_output-light.
ENDIF.
APPEND wa_output TO gt_output.
* CLEAR: wa_output,
* wa_sood.
ENDIF.
ENDLOOP. -
Insert multiple rows from cursor to table
Hi,
I want to insert multiple rows retrieved from cursor to a table without looping the cursor till the end of cursor.
I have the following structure, plz guide me.
Create procedure procedure_name as
cursor mycursor as
select * from table1; --returns multiple row
t_data table1%rowtype;
begin
fetch mycursor to t_data;
loop
exit when cursor not found;
insert to table2
end loop;
end procedure;
===========================
Now my cursor contains multiple records. I can iterate the records in loop and insert data to another table e.g table2 with same structure.
But I want to insert the total data at a time without looping the cursor for each data.Please suggest how to do this ?
Thanks in advance.You should be able to do it in a single statement (assuming table1 and table2 have the same columns/datatypes)
insert into table2 (select * from table1); -
Deleting multiple rows from SUD dialog table
Hi,
I have some SUD dialog tables that I would like to delete some rows from. I can select and delete all or one row (using a SUD button that finds out which one row was selected or if all, and then deleting them with the table.rows.remove command), but I seem to have troubles if I want to select multiple rows (either in a range, ex: rows 3-10, or non-sequential, ex: 1, 4, 6 and 23). I just started working on this but thought maybe someone has already done this and can save me the trouble!
Thanks!
Julia MoellerHi Julia,
Just a quick guess-- try looping backwards and deleting the last rows first:
FOR i = 10 TO 3 Step -1
table.rows.remove i
NEXT
Haven't tested it, so no guarantees,
Brad Turpin
DIAdem Product Support Engineer
National Instruments -
What happen if I delete the Blank row in Master Data Table
This is what happened:
I have an InfoObject Item has only the key and description. I wrote a program to delete all Master Data in Item.
DELETE FROM /bic/TItem.
DELETE FROM /bic/SItem.
COMMIT WORK.
I still able to load Master Data to Item succussfully without a blank row. But I remember 1 blank row always gets inserted to the table, right? In my case, it's not ture. I would like to know why and what's going to affect if there is no blank row in the table?
Thanks.Hi,
I guess there should be no impact but why do you want to delete the row. I guess at some point the system would still insert a blank record.
Bye
Dinesh -
Retriving multiple rows from the same table
Hi all,
I have a table consisting of an id column as well as a start and end date.
What I want to do is select the difference between start and end time for different id's.
For example select (endtime where id = 1 - starttime where id = 2).
Is this possible to do using a single select statement?
Thanks pplOK, so you want every combination of dropped_id 500 with dropped_id 1000? For example:
WITH test_data as (SELECT 500 dropped_id, TO_DATE('13/05/2009', 'DD/MM/YYYY') insert_date, TO_DATE('12/05/2009 12:00:00', 'DD/MM/YYYY HH24:MI:SS') starttime, TO_DATE('12/05/2009 12:30:00', 'DD/MM/YYYY HH24:MI:SS') endtime FROM DUAL UNION ALL
SELECT 500, TO_DATE('12/05/2009', 'DD/MM/YYYY'), TO_DATE('11/05/2009 12:04:00', 'DD/MM/YYYY HH24:MI:SS') starttime, TO_DATE('11/05/2009 12:41:00', 'DD/MM/YYYY HH24:MI:SS') endtime FROM DUAL UNION ALL
SELECT 500,TO_DATE('11/05/2009', 'DD/MM/YYYY'), TO_DATE('10/05/2009 12:18:00', 'DD/MM/YYYY HH24:MI:SS') starttime, TO_DATE('10/05/2009 12:59:00', 'DD/MM/YYYY HH24:MI:SS') endtime FROM DUAL UNION ALL
SELECT 1000,TO_DATE('13/05/2009', 'DD/MM/YYYY'), TO_DATE('12/05/2009 12:30:00', 'DD/MM/YYYY HH24:MI:SS') starttime, TO_DATE('12/05/2009 13:30:00', 'DD/MM/YYYY HH24:MI:SS') endtime FROM DUAL UNION ALL
SELECT 1000,TO_DATE('12/05/2009', 'DD/MM/YYYY'), TO_DATE('11/05/2009 12:41:00', 'DD/MM/YYYY HH24:MI:SS') starttime, TO_DATE('11/05/2009 14:30:00', 'DD/MM/YYYY HH24:MI:SS') endtime FROM DUAL UNION ALL
SELECT 1000,TO_DATE('11/05/2009', 'DD/MM/YYYY'), TO_DATE('10/05/2009 12:19:00', 'DD/MM/YYYY HH24:MI:SS') starttime, TO_DATE('10/05/2009 13:30:00', 'DD/MM/YYYY HH24:MI:SS') endtime FROM DUAL)
-- end test data
SELECT tab1.insert_date insert_date1, tab2.insert_date insert_date2, tab1.dropped_id dropped_id1, tab2.dropped_id dropped_id2, ROUND(tab2.endtime - tab1.starttime,2) time_diff
FROM test_data tab1
CROSS JOIN test_data tab2
WHERE tab1.dropped_id = 500
AND tab2.dropped_id = 1000;
INSERT_DA INSERT_DA DROPPED_ID1 DROPPED_ID2 TIME_DIFF
13-MAY-09 13-MAY-09 500 1000 .06
12-MAY-09 13-MAY-09 500 1000 1.06
11-MAY-09 13-MAY-09 500 1000 2.05
13-MAY-09 12-MAY-09 500 1000 -.9
12-MAY-09 12-MAY-09 500 1000 .1
11-MAY-09 12-MAY-09 500 1000 1.09
13-MAY-09 11-MAY-09 500 1000 -1.94
12-MAY-09 11-MAY-09 500 1000 -.94
11-MAY-09 11-MAY-09 500 1000 .05
9 rows selected. -
FWD: Re: Retrieving multiple rows from a database into morethan
There are two ways to do this that I cn think of right off the bat.
One is to create a class of objects that can receive the entire row, and
give it methods that will return each of the individual objects that you are
looking for when called. If you use INTO :ARRAY, you get the advantage of
being able to pass the array anywhere in your system for the 'split up'
processing.
Two is to do basically the same thing, but instead doing the 'split up'
during a for loop. This will appear to slow down your query, however, as
extra processing will be occuring in terms of memory allocation and copying.
I'm sure there other approaches. This was simply what came to mind at
midnight, after a long day :-).
At 01:33 AM 6/4/96 +0000, you wrote:
Does anyone know of a way to retrieve multiple rows from a single table in an
RDB database into more than 1 object, using a single SQL call?
I have a single table that I wish to use some fields to populate one object
and some others to populate another.
The FOR clause only allows one object to be specified.
The INTO :ARRAY clause also seems to only allow one object to be specified.
I would appreciate any help.
Regads,
Steve Isaac
Hydro Electric Commission
Hobart TAS 7001
Australia
[email protected]
James Urquhart Voice: (510)869-3400
[email protected] Fax: (612)921-8243
Forte Consultingwow, that was pleasant, the usual format goes:
Newb: I have a problem, fix it for me
Forum: Here's a link explaning the concept you obviously don't grasp
Newb: No, fix it FOR me
Forum: I'll fix you!
Newb: WAAAAH!
Forum: BAN! -
Multiple Selection from a data block
Hello,
I have a data block returning the names and surnames of employees. Can I select multiple rows from that data block?
Thank youYou could put a checkbox on the row and if it is ticked then interpret this as a selected row.
Sometimes it is useful to store this type of selection in some type of structure like a record group or index by table and process those rows rather than read the data block -
Field not being updated in Master Data table
Hi guys,
I'm pulling data from master data in BW... specifically 0ven_compc. I haven't added any new fields to this maser data table, and one field that I'm trying to pull is not being populated. In the master data table this field is blank, but in the PSA there are values. Somehow the values are not being loaded into the master data table. I've checked the transfer rules and communication structure and everything looks fine. Why is this happening?
Thanks,
AnthonyHi Anthony,
The problem may be that there is an inconsistency with the target master data infoobject. Please make a dummy change to the target infoobject (i.e you can change the description), save this change and then click on the activate icon. Please then check if the field is filled with the next load.
If the problem still exists please let us know your BI version and support package level.
Best Regards,
Des.
Maybe you are looking for
-
Credit Memo Creation - Sold-to-party / Ship-to-party fields
I am trying to create a SD Credit memo document. From the thread Credit Memo Creation I understand that the BAPI BAPI_SALESORDER_CREATEFROMDAT2 cant be used and instead I gotta use the FM SD_SALESDOCUMENT_CREATE for this purpose. On this backdrop,
-
Help with Autocad Drawings in Acrobat 7.0 Professional
I am trying to convert .dwg files created from Autocad 2006 Lite to .pdf files. However, when i try to open the .dwg files an error pops up that says "Could not find the application that created this file: (file path here) Please select a file create
-
My new installation of Flash CS5 acts very buggy. Keyboard shortcuts stop working, and I can pick fill colors but not text or line colors - just have a gray box with a few horizontal/vertical lines. Is this a known bug? Is there an easy fix? Clos
-
I like to listen to my music by genre. In my library I have assigned each song a specific genre. However when I purchased music from itunes, it created a duplicate genre list on my ipod. For example, I have two lists for children's music. One has my
-
Word 2001 is Missing the "File" Menu
I am missing the "FILE" menu from word. I Have the apple menu edit, view, insert, format etc... but "FILE" is missing. I rebuilt the desktop trashed word's preferences, zapped PRAM. Copied the App from a cloned hard drive but "FILE" will not come bac