How to get CJ20N project hierarchy? - abap

I need to get the hierarchy of a project (like shown in transaction CJ20N) in ABAP.
I've found a function module 'GET_PROJECT_HIERARCHY', which delivers me a table like this:
However, I rather need all WBS elements, order numbers, purchase requests and network elements (AUFNR) in this project. Is there a better function module or a next step to the GET_PROJECT_HIERARCHY?

At least what concerns WBS elements you can get them from table PRPS
DATA: lt_prhi TYPE TABLE OF prhi.
CALL FUNCTION 'GET_PROJECT_HIERARCHY'
EXPORTING
i_pronr = '00000113'
TABLES
t_prhi = lt_prhi.
SELECT * FROM prps
INTO TABLE #DATA(lt_prps)
FOR ALL ENTRIES IN lt_prhi
WHERE pspnr = lt_prhi-posnr.
cl_demo_output=>display( lt_prps ).

Thank you Suncatcher, your directed me the right way with the PRPS table and I'll accept your answer.
I finally decided to build a custom query, looking in the tables PRPS, AFVC, AUFK, AFKO and PROJ to get all the data I want using the PSPHI column from GET_PROJECT_HIERARCHY.
I just wanted to post my solution, maybe it helps others too.
SELECT
PROJ~PSPID,
PROJ~POST1 AS PROJ_NAME,
PRPS~POST1 AS WSB_NAME,
AFVC~LTXA1,
AUFK~KTEXT
FROM
PRPS
LEFT JOIN PROJ ON PROJ~PSPNR = PRPS~PSPHI
LEFT JOIN AUFK ON AUFK~PSPEL = PRPS~PSPNR
LEFT JOIN AFKO ON AUFK~AUFNR = AFKO~AUFNR
LEFT JOIN AFVC ON AFKO~AUFPL = AFVC~AUFPL
WHERE
PRPS~PSPHI = '00000136'
INTO TABLE #DATA(LT_RESULT)

Related

display the same column twice with different results

I have a column that contains Enable and Disable values, which is associated by an event id, in this event table I have the user datatime, I would like to create a query and display the time the enabled event was triggered and in the same row. the time the disable was triggered
SELECT
valv.valvOf, valv.cam,
cod.descOf Habilita, cod.descof Desabilita
FROM
{oj (aspersao.dbo.events events LEFT JOIN aspersao.dbo.valv valv ON events.valv_id = valv."id") LEFT JOIN aspersao.dbo.cod cod ON events.cod_id = cod.id}
WHERE
valv.cam = '1'
and
Habilita = 'Habilitou valvula'
and
Desabilita = 'Desabilitou valvula'
Even after correcting your code so that you are not trying to refer to columns by their aliases in the WHERE clause, your code is nonsense. No row will have a column equal to two different values.
Likely you want to pull in the table twice. I'm also getting rid of the ODBC specific curly brace syntax.
SELECT
valv.valvOf, valv.cam,
cod1.descOf AS Habilita, cod2.descof AS Desabilita
FROM
aspersao.dbo.events AS events
LEFT JOIN aspersao.dbo.valv AS valv ON events.valv_id = valv."id"
LEFT JOIN aspersao.dbo.cod AS cod1
ON events.cod_id = cod1.id
AND cod1.descOf = 'Habilitou valvula'
LEFT JOIN aspersao.dbo.cod AS cod2
ON events.cod_id = cod2.id
AND cod2.descOf = 'Desabilitou valvula'
WHERE
valv.cam = '1'
This is pretty much a guess because there really isn't enough info in your question.
EDIT: I had the wrong test string in the cod2.descOf = line; I've fixed that.

OracleAPPS- Can not get correct results for Suppliers - Bank query

I am trying to fetch suppliers and bank details in Oracle apps. I am able to write a simple query where each supplier has a supplier site attached to it. Few of my sites doesn't have a record in table "iby_pmt_instr_uses_all". But even then I want to show them . So I am using the outer join on this table. But the issue is when I am putting this outer join condition, I am getting double the records in the query. I believe I am missing on some condition, but can not figure out which one.
SELECT *
FROM apps.iby_pmt_instr_uses_all instrument,
apps.iby_account_owners owners,
apps.iby_external_payees_all payees,
apps.iby_ext_bank_accounts ieb,
apps.ap_supplier_sites_all asa,
apps.ap_suppliers asp,
apps.ce_bank_branches_v cbbv
WHERE owners.ext_bank_account_id = ieb.ext_bank_account_id
AND owners.ext_bank_account_id = instrument.instrument_id(+)
AND payees.ext_payee_id = instrument.ext_pmt_party_id(+)
AND cbbv.branch_party_id = ieb.branch_id
AND payees.payee_party_id = owners.account_owner_party_id
AND payees.supplier_site_id = asa.vendor_site_id
AND asa.vendor_id = asp.vendor_id
AND asp.vendor_name = 'PANALYTICAL'
--and ieb.bank_account_num = asa.VENDOR_SITE_CODE
If I add and ieb.bank_account_num = asa.VENDOR_SITE_CODE this condition I get the correct record, but actually this is not the right join, because there is no relationship between these 2 columns, so this will fail for other suppliers.
Can you please suggest what additional join I can put , so that I get the right result.
Thanks

Long Text Field over 255 Characters gets truncated

Not sure why my field in my query is getting truncated upon the return of the result. The value is being stored in the field, but gets truncated by access to help with "performance". I have reviewed multiple forums and SO posts to no avail.
Problems listed at link do not apply, Aggregation, Uniqueness, Union, Format Property, Row Source
What is wrong with my query? Instructions field in the Customer table is the one that is getting truncated.
Here is the raw query generated by access:
SELECT Task.ID, Task.TaskID, Task.TaskName, Task.TypeID, TaskType.TaskTypeName, Task.CustomerID, Customer.CustomerName, Customer.OnHold, Customer.Blacklisted, Customer.CustomerEngagementRecieved, Customer.AutoEmail, Customer.SpecialInstructions, Customer.Instructions, Task.QuoteRequired, Task.PriorityID, Priority.Priority, Task.Min, Task.Max, Task.Projected, Task.DeadlineDate, Task.ResourceID, Resource.ResourceName, Resource.Email, Resource.Extension, Task.Description, Task.StatusID, Status.Status, Task.DeveloperLog, Task.TaskPOCID, POC.Phone, POC.Email, Task.OtherPOC, Task.OtherPOCPhone, Task.OtherPOCEmail, Task.FolderPath, Task.StopBilling, Task.Premium, Task.EntryDate, Task.CompleteDate, Task.AssignedBy, Task.SettingsID, Settings.AutoEmail
FROM TaskType
INNER JOIN (Status
INNER JOIN (Settings
INNER JOIN (Resource
INNER JOIN (Priority
INNER JOIN (Customer
INNER JOIN (Task
INNER JOIN POC ON Task.TaskPOCID = POC.POCID)
ON Customer.CustID = Task.CustomerID)
ON Priority.PriorityID = Task.PriorityID)
ON Resource.ResourceID = Task.ResourceID)
ON Settings.SettingsID = Task.SettingsID)
ON Status.StatusID = Task.StatusID)
ON TaskType.TTID = Task.TypeID;
`
Have a close read of this - http://allenbrowne.com/ser-63.html something in your set up will causing the truncation.
If it's when you cut and paste the query results that can also be mis-leading. When you say a Long Text are these linked tables?
I'd also rename your Min and Max fields as they are reserved words and may cause access to think you are aggregating your data.
So from the sounds of it, Access just sometimes will ALWAYS truncate the field no matter what the settings. There is a way to force access to show the entire field though, by using the DLOOKUP() function instead of using a Control Source.
Here is the Answer to my current Issue for reference,
=DLOOKUP("Instructions", "Customer", "CustID=" & [CustomerID])

SQL Join and filter even further

I need to add a condition that only selects the rows where a field (my_galleries.format) equals a string value of 'pictures'. I am trying to add it to this working sql statement.
SELECT
gallery_url,
preview_url
FROM
my_galleries,
my_gallery_previews
WHERE
my_galleries.gallery_id = my_gallery_previews.gallery_id
I tried this, with no luck....
SELECT
gallery_url,
preview_url
FROM
my_galleries,
my_gallery_previews
WHERE
my_galleries.gallery_id = my_gallery_previews.gallery_id
AND my_galleries.format='pictures'
Any ideas?
I recommend not using the FROM foo, bar WHERE foo.key = bar.key approach to performing a JOIN as it isn't very flexible and isn't obvious to new readers of your code. Instead you should perform an explicit JOIN instead:
SELECT
gallery_url,
preview_url
FROM
my_gallery_previews
INNER JOIN my_galleries ON my_gallery_previews.gallery_id = my_galleries.gallery_id
WHERE
my_galleries.format = 'pictures'
How about you try this
SELECT gallery_url, preview_url FROM my_galleries
JOIN my_gallery_previews ON
my_galleries.gallery_id = my_gallery_previews.gallery_id
WHERE my_galleries.format='pictures'
With the join, make sure to prefix your selected columns with their respective tables. I hope this helps
As others have stated I recommend you use the new structure of joining as it is more readable.
SELECT mg.gallery_url,
mgp.preview_url
FROM my_galleries mg
JOIN my_gallery_previews mgp ON mg.gallery_id = mgp.gallery_id
AND mg.format = 'pictures'
You can place the filter condition in the join using an AND statement. (Just another way to do it)
Your query appears to be correct syntax. I would recommend going through your data set or editing it into your question. It is possible that no picture gallery previews currently share a gallery id with an existing gallery row which is stopping the join from functioning.

What is similar to CHANGE_TRACKING_IS_COLUMN_IN_MASK in CDC?

I am working on an application to synchronize data. We decided to use CDC in place of CT because we need more information, but at the same time we need a function which return the column which changing affects it something like this using CT:
SELECT
CTTable.SYS_CHANGE_OPERATION,
[FNameCh] = CHANGE_TRACKING_IS_COLUMN_IN_MASK(COLUMNPROPERTY(OBJECT_ID('CONTACT_TABLE'),
'contact_name', 'ColumnId'), SYS_CHANGE_COLUMNS),
[LNameCh] = CHANGE_TRACKING_IS_COLUMN_IN_MASK(COLUMNPROPERTY(OBJECT_ID('CONTACT_TABLE'),
'contact_lastname', 'ColumnId'), SYS_CHANGE_COLUMNS),
FROM CHANGETABLE (CHANGES Contacts, #VersionId) AS CTTable
LEFT OUTER JOIN Contacts AS C ON C.CONTACT_ID = CTTable.CONTACT_ID
GO
EDIT:
SELECT * , sys.fn_cdc_has_column_changed ('dbo_CONTACT_TABLE', 'contact_name', __$update_mask) AS FNameCh
From cdc.fn_cdc_get_all_changes_dbo_CONTACT_TABLE(#Start_Lsn,#End_Lsn,'all')
which 1 for if the contact_name is changed and 0 if is not.
Thanks
We can identify using sys.fn_cdc_is_bit_set. Please find the link below for detailed information
http://msdn.microsoft.com/en-us/library/bb500241.aspx