Combining DD-MON field with YYYY field from GL table
I am running into issues with GL_Cancelled_Date which is displaying the wrong 4 digit year. The GL_Encumbered_Date for these rows is correct and I am looking at ways to combine these fields to output the correct full DD-MON-YYYY date. The below code displays all of the bad rows of data and the last two coloumns display the correct DD-MON and YYYY dates. But I am unsure of how to combine the DD-MON from GL_Cancelled_Date with the YYYY from GL_Encumbered_Date.
I have written out:
SELECT
PRH.SEGMENT1,
prd.GL_ENCUMBERED_DATE,
TO_CHAR(PRD.GL_ENCUMBERED_DATE,'YYYY'),
PRD.GL_CANCELLED_DATE,
TO_CHAR(PRD.GL_CANCELLED_DATE, 'DD-MON-YYYY'),
to_char(prd.gl_cancelled_date,'YYYY'),
to_char(prd.gl_cancelled_date,'DD-MON-') as date_day_month,
to_char(prd.gl_encumbered_date,'YYYY') as date_year
FROM
PO_REQUISITION_HEADERS_ALL PRH,
PO_REQUISITION_LINES_ALL PRL,
PO_REQ_DISTRIBUTIONS_ALL PRD
WHERE
PRH.REQUISITION_HEADER_ID = PRL.REQUISITION_HEADER_ID
AND PRL.REQUISITION_LINE_ID = PRD.REQUISITION_LINE_ID
AND PRD.GL_CANCELLED_DATE IS NOT NULL
AND to_char(PRD.GL_CANCELLED_DATE,'YYYY') LIKE '00%';
Hi,
Here's one way to correct the table:
UPDATE po_req_distributions_all
SET gl_cancelled_date = ADD_MONTHS ( gl_cancelled_date
, 12 * ( EXTRACT (YEAR FROM gl_encumbered_date)
- EXTRACT (YEAR FROM gl_cancelled_date)
WHERE EXTRACT (YEAR FROM gl_encumbered_date)
<> EXTRACT (YEAR FROM gl_cancelled_date)
When this finishes, gl_cancelled_date will always have the same year as gl_encumbered_date, but hte original months, days, hours, minutes and seconds of gl_cancelled_date will be unchanged. (Exception: If the original gl_cancelled_date is February 29, and gl_encumbered_date is NOT in a leap year, then the day will be changed to 28, since there is no February 29 in the correct year. If the original gl_cancelled_date is February 28, and gl_encumbered_date IS in a leap year, then the day will be changed to 29. This can be fixed if it's a problem.)
I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and also post the results you want from that data.
If you're asking about a DML statement, such as UPDATE, the sample data will be the contents of the table(s) before the DML, and the results will be state of the changed table(s) when everything is finished.
Point out where the statement above is getting the wrong results, and explain, using specific examples, how you get the right results from the given data in those places.
Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
See the forum FAQ: https://forums.oracle.com/message/9362002
Similar Messages
-
I need to add a single field from with_item table . need to write select query with reference to company code , account doc no , fiscal year
Hi Arun ,
Can you explain little bit more ??
what is account doc no?
what are the transactions should be displayed in your output??
-Rajesh N -
How to print the data if we take different fields from diffrent tables
Hi ABAPers,
I take diff fields from 3 tables. Those are
these fields from EKBE
EBELN
EBELP
BELNR
BUZEI
BWART
BUDAT
AREWR
REEWR
WERKS
MWSKZ
these fields from EKKO
BUKRS
BSART
WAERS
these field from EKPO
TXZ01
MATNR
MTART
I want to print the data all fields.What logic can i write?
Please help me for this question and i am waiting for your response.
Regards,
Raja Sekhar.Hi,
First you have to fetch data from all the three tables and then consolidate into final table.
In Declaration:
1.Declare Internal Table for EKKO holding:
EBELN
BUKRS
BSART
WAERS
2.Declare Internal Table for EKPO holding:
EBELN
EBELP
TXZ01
MATNR
MTART
3.Declare Internal Table for EKBe holding:
EBELN
EBELP
BELNR
BUZEI
BWART
BUDAT
AREWR
REEWR
WERKS
MWSKZ
*==> This table has
MANDT
EBELN
EBELP
ZEKKN
VGABE
GJAHR
BELNR
BUZEI
as Primary keys field,you should have values for all the PK aotherwise you will get multiple entries*
4.Declare a Final Internal Table i_final with all the fields you want
EBELN
EBELP
BUKRS
BSART
WAERS
TXZ01
MATNR
MTART
BELNR
BUZEI
BWART
BUDAT
AREWR
REEWR
WERKS
MWSKZ
Data Fetching
select EBELN
BUKRS
BSART
WAERS
from EKKO
into table i_ekko
where .........<selection criteria>.
if not i_ekko is initial.
select EBELN
EBELP
TXZ01
MATNR
MTART
from EKPO
into table i_ekpo
for all entries in i_ekko
where EBELN = I_EKKO-EBELN
AND ......<If any other selection criteria>.
if not i_ekpo is initial.
select EBELN
EBELP
BELNR
BUZEI
BWART
BUDAT
AREWR
REEWR
WERKS
MWSKZ
from EKBE
into table i_ekbe
for all entries in i_ekpo
where ebeln = i_ekpo-ebeln
and ebelp = i_ekpo-ebelp
and ..........<If any othet selection criteria>
endif.
endif.
Consolidate
sort i_ekko by ebeln.
sort i_ekpo by ebeln ebelp.
sort i_ekbe by ebeln ebelp.
LOOP AT i_ekbe into wa_ekbe.
read table i_ekko into wa_ekko with key ebeln = wa_ekbe-vbeln binary search.
if sy-subrc = 0.
====>Move all the required firlds from I_EKKO to i_final , like
wa_final-BUKRS = wa_ekko-BUKRS.
endif.
read table i_ekpo into wa_ekpo with key ebeln = wa_ekbe-vbeln
ebelp = wa_ekbe-ebelp binary search.
if sy-subrc = 0.
====>Move all the required firlds from I_EKPO to i_final , like
wa_final-EBELP = wa_ekko-EBELP.
wa_final-TXZ01 = wa_ekko-TXZ01.
endif.
==>Also all the required fields from EKBE to final table, like
wa_final-BELNR = wa_ekbe-BELNR.
endloop. -
No records when inputting new field from linked tables.
I have linked two tables in a report. If I use only fields from one table, no problem. As soon as I add a field from the other table no records are pulled. I am using the same filed "IncidentID" in both tables as a link. If I attempt to pull the "IncidentID" from the second table no records are pulled. There does not appear to be any key fields or indexes in either table if that helps.
Here are the SQL queries. The first string is without any fields from "WorkLog". The second is after adding the field "WorkLog.Incident Number" to the form.
SELECT "HPD_Help_Desk"."Incident Number", "HPD_Help_Desk"."Reported Date", "HPD_Help_Desk"."Direct Contact Site", "HPD_Help_Desk"."Assignee", "HPD_Help_Desk"."Status", "HPD_Help_Desk"."Last Modified Date", "HPD_Help_Desk"."Description", "HPD_Help_Desk"."Priority"
FROM "HPD:Help Desk" "HPD_Help_Desk"
WHERE "HPD_Help_Desk"."Status"='Pending' AND ("HPD_Help_Desk"."Assignee"='Debbie Kiolbasa' OR "HPD_Help_Desk"."Assignee"='John L King' OR "HPD_Help_Desk"."Assignee"='Ligaya Plumlee' OR "HPD_Help_Desk"."Assignee"='Ryan Keeler')
ORDER BY "HPD_Help_Desk"."Assignee"
SELECT "HPD_Help_Desk"."Incident Number", "HPD_Help_Desk"."Reported Date", "HPD_Help_Desk"."Direct Contact Site", "HPD_Help_Desk"."Assignee", "HPD_Help_Desk"."Status", "HPD_Help_Desk"."Last Modified Date", "HPD_Help_Desk"."Description", "HPD_Help_Desk"."Priority", "HPD_WorkLog"."Incident Number"
FROM "HPD:Help Desk" "HPD_Help_Desk" INNER JOIN "HPD:WorkLog" "HPD_WorkLog" ON ("HPD_Help_Desk"."Incident Number"="HPD_WorkLog"."Incident Number") AND ("HPD_Help_Desk"."InstanceId"="HPD_WorkLog"."InstanceId")
WHERE "HPD_Help_Desk"."Status"='Pending' AND ("HPD_Help_Desk"."Assignee"='Debbie Kiolbasa' OR "HPD_Help_Desk"."Assignee"='John L King' OR "HPD_Help_Desk"."Assignee"='Ligaya Plumlee' OR "HPD_Help_Desk"."Assignee"='Ryan Keeler')
ORDER BY "HPD_Help_Desk"."Assignee"
BTW - The "Left Outer Join" receives the errors noted in above post whereas the default "Inner Join" just comes back with empty records.
Unable to use the third party tools due to restrictions on loading software. Also we are unable to access the lower level database.
Thanks -
Hi There,
In SAP GRC 10.0, our team had an issue where we could not add duplicate fields from separate table (see ERROR: Select Currency/UoM field for the selected analyzed fields). This was resolved by the SAP Note 1904313/ 1904314 (http://service.sap.com/sap/support/notes/1904313).
We upgraded our system to SAP GRC 10.1 SP05 and could now add the duplicate fields from separate tables. SAP Note 1904313/ 1904314 was part of SAP GRC 10.1 SP03 so it makes sense that we, in a higher version (SP05), would be able to do this.
The issue now is when we add the duplicate fields from different tables and run the Ad-hoc Query to test if the data source works correctly, the No Data Selected warning persists. This means that the data source provides no data for analysis, which is required to write our business rules.
Below is an example:
Basic data source with just one currency reference field EBAN-WAERS.
When you run the Ad-Hoc Query you receive data.
Basic data source with second currency reference field EKKO-WAERS.
When you run the Ad-Hoc Query no data is found.
Please also make reference to the following thread logged by my colleague (ERROR: Select Currency/UoM field for the selected analyzed fields)
Any assistance to receive data with duplicate fields from separate tables will be highly appreciated.
Thanking you in advance.
Regards
Gary KhanHi
following are the error messages from dump
hrtText
There is already a line with the same key.
hat happened?
Error in ABAP application program.
The current ABAP program "SAPLCKMS" had to be terminated because one of the
statements could not be executed.
This is probably due to an error in the ABAP program.
rror analysis
You wanted to add an entry to table "\FUNCTION-POOL=CKMS\DATA=T_DYN_CKMLCR",
which you declared
with a UNIQUE KEY. However, there was already an entry with the
same key.
This may have been in an INSERT or MOVE statement, or within a
SELECT ... INTO statement.
In particular, you cannot insert more than one initial line into a
table with a unique key using the INSERT INITIAL LINE... statement.
rigger Location of Runtime Error
Program SAPLCKMS
Include LCKMSF01
Row 226
Module type (FORM)
Module Name DYNAMIC_PERIOD_CLOSING
Source code where dump ocured
222
223 APPEND ht_ckmlpp TO t_add_ckmlpp.
224 APPEND LINES OF ht_ckmlcr TO t_add_ckmlcr.
225 INSERT ht_ckmlpp INTO TABLE t_dyn_ckmlpp.
>>>> INSERT LINES OF ht_ckmlcr INTO TABLE t_dyn_ckmlcr.
227 ENDWHILE.
Also I guess there is problem with material ledger in R/3 side
I have never worked on material ledger before so dont hav idea of Tcode and tables in SAP R/3 for material ledger.
Thanks
Navneet -
Drop down in the selection for the field from the table
Hi.
i want to put the drop down for the field from the table fo which i dont know the number of entries for the field zregion1 of the table zbwcntry.
please tell me how to use the function module and what could be the line of codes.
the drop down is for the select option on the slection screen of the classical report.
please help .HI,
Check below code..it may help you.
REPORT Zbunu .
TYPES :BEGIN OF STR ,
MATNR TYPE MATNR ,
END OF STR .
DATA : ITAB TYPE TABLE OF STR WITH HEADER LINE,
VAR TYPE MARA-MATNR .
PARAMETERS : S_MATNR TYPE MATNR ,
P_MATNR TYPE MATNR.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_MATNR .
SELECT MATNR FROM MARA INTO
CORRESPONDING FIELDS OF TABLE ITAB UP TO 1000 ROWS.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
DDIC_STRUCTURE = ' '
retfield = 'MATNR'
PVALKEY = ' '
DYNPPROG = SY-CPROG
DYNPNR = SY-DYNNR
DYNPROFIELD = 'S_MATNR'
STEPL = 0
WINDOW_TITLE =
VALUE = ' '
VALUE_ORG = 'S'
MULTIPLE_CHOICE = ' '
DISPLAY = 'X'
CALLBACK_PROGRAM = ' '
CALLBACK_FORM = ' '
tables
value_tab = ITAB
FIELD_TAB =
RETURN_TAB =
DYNPFLD_MAPPING =
EXCEPTIONS
PARAMETER_ERROR = 1
NO_VALUES_FOUND = 2
OTHERS = 3
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Regards
Ansumesh -
HI ALL,
I NEED FIELDS FROM VBFA TABLE
THE FIELDS I WANT IS :
CUSTOMER-ID
CUSTOMER NAME
CONTACT NAME
PROJECTID
ORDER NO
SALES MAN ID
ORDER PROCESS DATE
INVOICE DATE
GROSS AMOUNT
NET AMOUNT POSTAL CODE.
THANKS & REGARDS,
R.VINOD.Hi Vinod..
Try this Code. I made all the modifications in your code .. It will solve ur issues..
REPORT zsdr_omvsa40.
TYPE-POOLS
TYPE-POOLS: slis.
TABLE DECLARATIONS
TABLES : vbak, vbkd,
zzvbak,
kna1, vbrk, vbrp, knvp .
INTERNALTABLE DECLARATION *
DATA: BEGIN OF i_vbak OCCURS 0,
vbelv LIKE vbfa-vbelv, " Sales Order no
vbeln like vbfa-vbeln, "Invoice No
erdat LIKE vbak-erdat, " Date on Which Record Was Created
kunnr LIKE vbak-kunnr,
ps_psp_pnr LIKE vbak-ps_psp_pnr, " Work Breakdown Structure Element
END OF i_vbak.
*DATA : BEGIN OF i_zzvbak OCCURS 0,
*vbeln LIKE zzvbak-vbeln,
*zssidc LIKE zzvbak-zssidc, "Salesman ID
*END OF i_zzvbak.
DATA : BEGIN OF i_vbrk OCCURS 0,
vbeln LIKE vbrk-vbeln,
fkdat LIKE vbrk-fkdat, "Invoice Date
END OF i_vbrk.
DATA : BEGIN OF i_kna1 OCCURS 0,
kunnr LIKE kna1-kunnr , " Customer Number 1
name1 LIKE kna1-name1, " Customer Name
pstlz LIKE kna1-pstlz , " Postal Code
END OF i_kna1.
DATA : BEGIN OF i_vbrp OCCURS 0,
vbeln LIKE vbrp-vbeln,
aubel LIKE vbrp-aubel,
netwr LIKE vbrp-netwr , " Net Value in Document Currency
kzwi1 LIKE vbrp-kzwi1, " Subtotal 1 from pricing procedure for condition
erdat LIKE vbrp-erdat, "Billing document.
END OF i_vbrp.
DATA : BEGIN OF i_knvp OCCURS 0,
parvw LIKE knvp-parvw , " Partner Function
kunnr LIKE knvp-kunnr ,
parnr LIKE knvp-parnr , " Number of contact person
END OF i_knvp .
DATA : BEGIN OF i_data OCCURS 0,
erdat LIKE vbak-erdat, " Date on Which Record Was Created
vbeln LIKE vbak-vbeln, " Sales Order no
fkdat LIKE vbrk-fkdat, " Invoice date.
kunnr LIKE kna1-kunnr , " Customer Number
ps_psp_pnr LIKE vbak-ps_psp_pnr, " Work Breakdown Structure Element
name1 LIKE kna1-name1, " Customer Name
netwr LIKE vbrp-netwr , " Net Value in Document Currency
kzwi1 LIKE vbrp-kzwi1, " Subtotal 1 from pricing procedure for condition
parvw LIKE knvp-parvw , " Partner Function
parnr LIKE knvp-parnr , " Number of contact person
*zssidc LIKE zzvbak-zssidc, "Salesman ID
pstlz LIKE kna1-pstlz , " Postal Code
END OF i_data.
ALV Declaraton
DATA: fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE,
gd_tab_group TYPE slis_t_sp_group_alv,
gd_layout TYPE slis_layout_alv,
it_listheader TYPE slis_t_listheader,
gd_repid LIKE sy-repid.
Selection - Screen
SELECTION-SCREEN : BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS creation FOR vbak-erdat . " Sales Order Date
SELECT-OPTIONS period FOR vbrk-fkdat . " Invoice Date
SELECT-OPTIONS order FOR vbak-vbeln . " Sales order no
SELECT-OPTIONS name FOR kna1-name1 . " Customer Name
SELECT-OPTIONS contact FOR knvp-parnr . " Contact Name.
*SELECT-OPTIONS ssid FOR zzvbak-zssidc . " Salesman ID
SELECT-OPTIONS project FOR vbak-ps_psp_pnr . " Work Breakdown Structure Element
SELECTION-SCREEN : END OF BLOCK b1.
START-OF-SELECTION
START-OF-SELECTION.
PERFORM data_retrieval.
PERFORM build_fieldcatalog.
PERFORM BUILD_LAYOUT.
PERFORM top_of_page.
PERFORM fill_listheader USING it_listheader.
PERFORM display_alv_report.
END-OF-SELECTION.
*TOP-OF-PAGE.
TOP-OF-PAGE.
END-OF-PAGE.
*& Form BUILD_FIELDCATALOG
text
FORM build_fieldcatalog.
fieldcatalog-fieldname = 'KUNNR'.
fieldcatalog-seltext_m = 'Sold to Party'.
fieldcatalog-col_pos = 0.
fieldcatalog-outputlen = 10.
fieldcatalog-emphasize = 'X'.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'NAME1'.
fieldcatalog-seltext_m = 'Hlev Customer'.
fieldcatalog-col_pos = 1.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'PARNR'.
fieldcatalog-seltext_m = 'Contact name'.
fieldcatalog-col_pos = 2.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'PS_PSP_PNR'.
fieldcatalog-seltext_m = 'Project ID'.
fieldcatalog-col_pos = 3.
fieldcatalog-do_sum = 'X'.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'VBELN'.
fieldcatalog-seltext_m = 'Sales Document Type'.
fieldcatalog-col_pos = 4.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'ZSSIDC'.
fieldcatalog-seltext_m = 'SSID'.
fieldcatalog-col_pos = 5.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'ERDAT'.
fieldcatalog-seltext_m = 'so date'.
fieldcatalog-col_pos = 6.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'FKDAT'.
fieldcatalog-seltext_m = 'inv date'.
fieldcatalog-col_pos = 7.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'KWZI1'.
fieldcatalog-seltext_m = 'gross amt'.
fieldcatalog-col_pos = 8.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'NETWR'.
fieldcatalog-seltext_m = 'net amt'.
fieldcatalog-col_pos = 9.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'PSTLZ'.
fieldcatalog-seltext_m = 'Postal code'.
fieldcatalog-col_pos = 10.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
ENDFORM. "BUILD_FIELDCATALOG
*& Form DATA_RETRIEVAL
text
FORM data_retrieval.
SELECT VBFAvbelv VBFAvbeln
VBAKerdat VBAKkunnr VBAK~ps_psp_pnr
INTO TABLE i_vbak
FROM VBFA
INNER JOIN vbak
ON VBFAVBELV = VBAKVBELN
WHERE VBAK~erdat IN creation
AND VBFA~vbelV IN ORDER
AND VBAK~ps_psp_pnr IN project
AND VBFA~VBTYP_N = 'M' "Subsequent doc is Invoice
AND VBFA~VBTYP_V = 'C' "Prec doc is Sales order
IF NOT i_vbak[] IS INITIAL.
**Change of ORDER in SELECTS HERE
SELECT vbeln fkdat FROM vbrk INTO TABLE i_vbrk
FOR ALL ENTRIES IN i_vbak
WHERE vbeln = i_vbak-vbeln
AND fkdat IN period.
IF NOT i_vbrk[] IS INITIAL.
SELECT vbeln aubel netwr kzwi1 FROM vbrp INTO TABLE i_vbrp
FOR ALL ENTRIES IN i_vbrk
WHERE VBELN = i_vbrk-vbeln.
endif.
SELECT kunnr name1 pstlz FROM kna1 INTO TABLE i_kna1 FOR ALL ENTRIES IN i_vbak
WHERE kunnr = i_vbak-kunnr
AND name1 IN name.
*SELECT vbeln zssidc FROM zzvbak INTO TABLE i_zzvbak FOR ALL ENTRIES IN i_vbak
*WHERE vbeln = i_vbak-vbeln
*AND zssidc IN ssid .
select netwr kzwi1 erdat from vbrp into table i_vbrp for all entries in i_vbak
where erdat = i_vbak-erdat.
SELECT kunnr parnr parvw FROM knvp INTO CORRESPONDING FIELDS OF TABLE i_knvp FOR ALL ENTRIES IN i_vbak
WHERE kunnr = i_vbak-kunnr
AND parvw = 'AP'
AND parnr IN contact.
ENDIF .
SORT I_VBAK BY VBELN .
SORT I_VBRK BY VBELN .
LOOP AT i_vbrp. "Invoice Item data
MOVE i_vbrp-netwr TO i_data-netwr .
MOVE i_vbrp-kzwi1 TO i_data-kzwi1.
READ table I_VBAK WITH KEY VBELN = I_VBRP-VBELN BINARY SEARCH. "Sales Order info
IF SY-SUBRC = 0.
MOVE I_VBAK-VBELV TO I_DATA-VBELN. "Sales Order no
MOVE I_VBAK-erdat TO I_DATA-erdat. " Date on Which Record Was Created
MOVE I_VBAK-kunnr TO I_DATA-KUNNR. "Customer No
MOVE I_VBAK-ps_psp_pnr TO I_DATA-ps_psp_pnr. " Work Breakdown Structure Element
endif.
READ TABLE I_VBRK WITH KEY VBELN = I_VBRP-VBELN BINARY SEARCH. "Invoice header info
IF SY-SUBRC = 0.
MOVE i_vbrk-fkdat TO i_data-fkdat.
endif.
READ TABLE I_KNA1 WITH KEY KUNNR = I_VBAK-KUNNR BINARY SEARCH. "Customer info
IF SY-SUBRC = 0.
MOVE i_kna1-kunnr TO i_data-kunnr.
MOVE i_kna1-name1 TO i_data-name1.
MOVE i_kna1-pstlz TO i_data-pstlz .
endif.
READ TABLE I_KNvp WITH KEY KUNNR = I_VBAK-KUNNR BINARY SEARCH. "Partner info
IF SY-SUBRC = 0.
MOVE i_knvp-parnr TO i_data-parnr.
endif.
APPEND i_data.
ENDLOOP.
ENDFORM. "DATA_RETRIEVAL
*& Form DISPLAY_ALV_REPORT
text
FORM display_alv_report.
GD_REPID = SY-REPID.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
i_callback_program = sy-repid
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
i_callback_top_of_page = 'TOP_OF_PAGE'
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
I_GRID_TITLE =
I_GRID_SETTINGS =
IS_LAYOUT =
it_fieldcat = fieldcatalog[]
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
IT_EVENTS =
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
I_HTML_HEIGHT_TOP = 0
I_HTML_HEIGHT_END = 0
IT_ALV_GRAPHICS =
IT_HYPERLINK =
IT_ADD_FIELDCAT =
IT_EXCEPT_QINFO =
IR_SALV_FULLSCREEN_ADAPTER =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = i_data.
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2 .
*IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
*ENDIF.
ENDFORM. "DISPLAY_ALV_REPORT
FORM FOR FILLING LISTHEADER *
FORM fill_listheader USING it_listheader TYPE slis_t_listheader.
DATA : wa_listheader TYPE slis_listheader.
wa_listheader-typ = 'H'.
wa_listheader-info = 'Noel Gifts International Limited '.
APPEND wa_listheader TO it_listheader.
wa_listheader-typ = 'S'.
wa_listheader-info = 'CUSTOMER CREDIT EXCEPTION REPORT' .
APPEND wa_listheader TO it_listheader.
CLEAR wa_listheader.
ENDFORM. "fill_listheader
*& Form top_of_page
text
FORM top_of_page.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = it_listheader.
ENDFORM. "top_of_page
REWARD IF HELPFUL. -
Read contents of changing fields from internal table
Hi Folks,
Please help me in my query below:
Consider there is a Z-table with two fields TABNAM and FIELD having values KNA1 and NAME1 respectively.
In my report I have fetched entries for customers from KNA1. Now based on the field from Z-table I want to populate a variable suppose V_FREE_VAR with the value from KNA1 table.
Here V_FREE_VAR is of CHAR200 so that it accomodate all types of values from KNA1.
The value of Z-table FIELD can change daily i.e next day the value may be PSTLZ.
So how can I read the particular field from internal table as the field to be read is dynamic.
Note: using case is not feasible.
Thanks in advance.
Regards,
Shardul@Hartmut P
As Rob said i want to get the value of the field from internal table. the code is something like this.
I_KNA1 contains records for customers.
Suppose values of Z-table are in internal table I_TEMP_TABLE.
Entries in I_TEMP_TABLE are as follows
TABNAME FIELDNAME
KNA1 NAME1
The value of FIELNAME in Z-table can be changed
Loop at I_TEMP_TABLE into WA_TEMP_TABLE.
Read I_KNA1 into WA_KNA1 with key KUNNR = '0001002234'.
IF SY-SUBRC EQ 0.
CASE WA_TEMP_TABLE-FIELDNAME.
WHEN 'NAME1'.
V_VAR = WA_KNA1-NAME1.
WHEN 'PSTLZ'
V_VAR = WA_KNA1-PSTLZ.
ENDIF.
But using case is not appropriate as KNA1 contains 176 fields. -
Fetch only required fields from SQL Table
Hi,
We have a table like below which will get data thru a job.
And I'm writing a Job/SP which will fetch 4 fields from that table and send them in a Email to Admins informing how many new employee are added newly.
How to loop thru these fields and not only there might be a chance where we will have 100 records and I need to take only first 30 of them and send.
EmpId
Empname
Deptname
Designation
Can any one has any solution on achieving this?
ThanksPlease refer the below link:
http://beyondrelational.com/modules/2/blogs/77/posts/11386/sql-server-t-sql-different-ways-to-generate-a-comma-separated-string-from-a-table.aspx
You need to use the Top30 query as your table in the script :
select top 30 EmpID,EmpName,DeptName,Designation
from tbl_name
order by EmpID
Eg: You may need to do for other columns:
--WARNING: THIS SCRIPT IS PROVIDED AS-IS AND WITHOUT
-- WARRANTY.
-- FOR DEMONSTRATION PURPOSES ONLY
--Step 01: Generate Temp table to store source data
DECLARE @NamesTable TABLE (Id INT,
Name NVARCHAR(50))
--Step 02: Generate test data
INSERT INTO @NamesTable VALUES (1,'A'),
(2,'D'),
(2,'C'),
(3,'E'),
(3,'H'),
(3,'G')
DECLARE @listIds VARCHAR(MAX) --DO NOT initialize this one!
SELECT @listIds = COALESCE(@listIds + ',' ,'') + Cast(nt.Id as varchar(10))
FROM @NamesTable nt Order by ID asc
DECLARE @listNames VARCHAR(MAX) --DO NOT initialize this one!
SELECT @listNames = COALESCE(@listNames + ',' ,'') + nt.Name
FROM @NamesTable nt Order by ID asc
SELECT 'EmpID: ' + @listIds+', EmpName: ' + @listNames -
BDC with MM01/ MM02 from MARA table
Can anybody suggest me for the following problem.
I want to construct a BDC with MM01/ MM02 from MARA table.
And I want the source file to be a notepad or Excel sheet. But i am not
getting, that how to write the data in Notepad/Excel sheet, to feed to the
master table according to the MM01/MM02 fields .This is the sample code for creation of flatfile for MM01 this will be definetly helping you to create a flatfile.
REPORT ZBDC_FF MESSAGE-ID BCTRAIN .
TYPES: BEGIN OF STU,
MATNR LIKE RMMG1-MATNR,
MBRSH LIKE RMMG1-MBRSH,
MTART LIKE RMMG1-MTART,
MAKTX LIKE MAKT-MAKTX,
MEINS LIKE MARA-MEINS,
END OF STU.
DATA WA_ITAB TYPE STU.
DATA ITAB TYPE TABLE OF STU.
WA_ITAB-MATNR = 'T1'. "MATERIAL NUMBER"
WA_ITAB-MBRSH = 'K'. "INDUSTRY SECTOR"
WA_ITAB-MTART = 'VKHM'. "MATERIAL TYPE"
WA_ITAB-MAKTX = 'TOOLEMATERIAL'. "MATERIAL DESCRIPTION"
WA_ITAB-MEINS = 'EE'. "BASE UNIT OF MEASURE"
APPEND WA_ITAB TO ITAB.
CLEAR WA_ITAB.
*WA_ITAB-MATNR = 'TOL2'. "MATERIAL NUMBER"
*WA_ITAB-MBRSH = 'M'. "INDUSTRY SECTOR"
*WA_ITAB-MTART = 'VKHM'. "MATERIAL TYPE"
*WA_ITAB-MAKTX = 'TOOLEMATERIAL'. "MATERIAL DESCRIPTION"
*WA_ITAB-MEINS = 'EA'. "BASE UNIT OF MEASURE"
*APPEND WA_ITAB TO ITAB.
*CLEAR WA_ITAB.
*WA_ITAB-MATNR = 'TOL3'. "MATERIAL NUMBER"
*WA_ITAB-MBRSH = 'M'. "INDUSTRY SECTOR"
*WA_ITAB-MTART = 'VKHM'. "MATERIAL TYPE"
*WA_ITAB-MAKTX = 'TOOLEMATERIAL'. "MATERIAL DESCRIPTION"
*WA_ITAB-MEINS = 'EA'. "BASE UNIT OF MEASURE"
*APPEND WA_ITAB TO ITAB.
*CLEAR WA_ITAB.
*WA_ITAB-MATNR = 'TOL4'. "MATERIAL NUMBER"
*WA_ITAB-MBRSH = 'M'. "INDUSTRY SECTOR"
*WA_ITAB-MTART = 'VKHM'. "MATERIAL TYPE"
*WA_ITAB-MAKTX = 'TOOLEMATERIAL'. "MATERIAL DESCRIPTION"
*WA_ITAB-MEINS = 'EA'. "BASE UNIT OF MEASURE"
*APPEND WA_ITAB TO ITAB.
*CLEAR WA_ITAB.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
FILENAME = 'C:\Documents and Settings\chiranjeevi\Desktop\BDC.TXT'
TABLES
DATA_TAB = ITAB
IF SY-SUBRC <> 0.
MESSAGE S999 WITH 'EXECUTED'.
ENDIF.
Cheers!!! -
Count(*) , group by with multiple columns from multiple tables involved
Hi all,
I am relatively new to SQL.
Currently I have these few requirements, to display quite a number of fields from 3 tables for display of report.
In my query I need to:
1.) count(*)
2.) select quite a number of fields from table 1,2,3
However when count(*) is used, grouped by has to be used to.
How do I actually use group by with so many columns to be selected?
I have actually used the query below, but the count(*) returns 1, the correct output should be 3 instead.
select count(*), table1.col1, table1.col2, table1.col3, table2.col3, table2.col4, table2.col6, table3.col1, table3.col4, table3.col5
from table1, table2, table3
where
<conditions>........................
group by table1.col1, table1.col2, table1.col3, table2.col3, table2.col4, table2.col6, table3.col1, table3.col4, table3.col5
I know this group by statement looks very unrefined. How can I select multiple fields from different tables, and yet get the count(*) correctly?
Thank you so much for your time.Hmm yes it actually does return count as 1 for each row. But there are 3 rows returned. E.g.
ctr table1.col1 table1.col2 ..........
1 value1 value1
1 value2 value3
1 value3 value4
If I put the count(*) outside, it returns 3 , the correct output
ctr
3
select count(*) from
select table1.col1, table1.col2, table1.col3, table2.col3, table2.col4, table2.col6, table3.col1, table3.col4, table3.col5
from table1, table2, table3
where
<conditions>
group by table1.col1, table1.col2, table1.col3, table2.col3, table2.col4, table2.col6, table3.col1, table3.col4, table3.col5
Thus I was wondering if it was the group by of multiple colns that resulted in the count stucked at value 1. -
Updating a date field witha field from another table
Hi friends
I have a table called Customer_Type with following fields
Customer_type ,Active_date, Inactive_date
regular,11/01/2011
daily,11/04/2011
monthly,11/05/2011/11/11/2011
Tbale 2:Customer
Customer_name,Customer_type,Customer_Inactive_date
John,regular,
James,monthly,
Jake,daily,
Jill,monthly
What i wnat is to update the Customer_inactive_date with the Incative_date field from Customer_type
based on their Customer_type... So james and Jill would have their rows updated in this scneario ..How can i achive this in pl/Sql
Thank you in advance...Hi,
You can look at this code; it's not PL/SQL but a simple MERGE statement:
CREATE TABLE CUSTOMER_TYPE
type_code VARCHAR2(10),
active_date DATE,
inactive_date DATE
INSERT INTO customer_type VALUES('REGULAR', TO_DATE('11/01/2011', 'DD/MM/YYYY'), null);
INSERT INTO customer_type VALUES('DAILY', TO_DATE('11/04/2011', 'DD/MM/YYYY'), null);
INSERT INTO customer_type VALUES('MONTHLY', TO_DATE('11/05/2011', 'DD/MM/YYYY'), TO_DATE('11/11/2011', 'DD/MM/YYYY'));
CREATE TABLE CUSTOMERS
customer_name varchar2(10),
customer_type varchar2(10),
customer_inactive_date DATE
INSERT INTO customers VALUES('John', 'REGULAR', null);
INSERT INTO customers VALUES('James', 'MONTHLY', null);
INSERT INTO customers VALUES('Jake', 'DAILY', null);
INSERT INTO customers VALUES('Jill', 'MONTHLY', null);
MERGE INTO customers dst
USING customer_type src
ON (dst.customer_type = src.type_code)
WHEN MATCHED THEN
UPDATE set dst.customer_inactive_date = src.inactive_date;
SELECT * FROM customers;
CUSTOMER_NAME CUSTOMER_TYPE CUSTOMER_INACTIVE_DATE
John REGULAR
James MONTHLY 11-NOV-11
Jake DAILY
Jill MONTHLY 11-NOV-11 If you don't understand it, just let me know... -
Combined more Data Fields from different segments in single report
Hi all,
i want to combined report from more then one segment(like 2 fields from Sales & Distribution & one Field from Inventory) then what should i do so far,
should i create cubes in respective segment,
either i create that but when i add it into Select item in that after selection of a field all of others segment disabled.Hi
By far the simplest method would be to concatenate the two fields in a calculation like this: FIELDA || FIELDB
Should you want spaces between them then do this: FIELDA || ' ' || FIELDB
If you want a dash and spaces either side you do this: FIELDA || ' - ' || FIELDB
Does this help?
Best wishes
Michael -
How to select and field from an table with similar value
Hi Gurus,
I got an requirement where i need to capture some values from an table whose value start with "vmr*"
could anyone tell me the syntax to be used with this?
My table contains valies like "lrt", "vmr'" nut i need only values starting with "vmr"*
RaviHi,
In where clause, you can write,
where field like 'vmr%'.
Hope this helps.
Reward if helpful.
Regards,
Sipra -
How to find internal table fields from which table.
Hello Experts,
I have to use a dynamic select inner join query.
SELECT (lv_string)
FROM (from_tab)
INTO CORRESPONDING FIELDS OF TABLE <fs_itab1>
WHERE (where_tab).
ELSEIF table_1 NE ''.
SELECT *
FROM (table_1)
INTO CORRESPONDING FIELDS OF TABLE <fs_itab1>
WHERE (where_tab).
in that LV_string is dynamicaly select. from a structure which is a combination of say VBAK and VBAP
i have to
CONCATENATE 'VBAK~' wa_fields-fname INTO str_temp.
CONCATENATE lv_string str_temp INTO lv_string SEPARATED BY space
CONCATENATE 'VBAP~' wa_fields-fname INTO str_temp.
CONCATENATE lv_string str_temp INTO lv_string SEPARATED BY space.
with there identifire....how to find that...
Regards,
Ketan.Ketan,
I believe you CAN find this only when you are creating lv_string from your structure (or whatever it is).
So paste that code that what is your 'structure' type and on what conditions you want to Fill lv_string from it.
in that LV_string is dynamicaly select. from a structure which is a combination of say VBAK and VBAP
If you have a custom or standard Structure from which you need to fill lv_string, then you should have no worries to full VBAK~ or VBAP~ because fieldnames will be always unique in any Structure and hence ~ additions are not necessarily needed.
The issue can be in the case where you are picking few fields each from std tables VBAK and VBAP in your lv_string and
your "(from_tab)" is an inner join condition. I believe in that case you should be able to identify VBAK~ and VBAP~ while populating lv_string itself. Also you can use DB view MASSVBAP.
Regards,
Diwakar -
ALV for fields from multiple tables and make them editable
Hi,
I am working on a forecasting report. We have created few custom table e.g. store forcaset detail for whole year month wise. tables are say sales data, budget data, forcast data etc.
Now i need to make a report based on monthwise based on above mention table.
eg.o/p looks like:
column name type desc monthapr monthmay .......
table forcast Qty sales 100 150
table budget/sales amt amou 20.50 130.50
table sales vs forcast amt amount 3000 50000
-Now i don't know how to display data from multiple table in single ALV list that to with different field type.
-2nd issue is i need to make only perticuler row editable so that user can chage data.
-3rd when user change data and press calulate button - it should calculate data for future month - i got formula for that and disply the calulated data.
- 4th if user like the forcast data then when press save - change data should update dbtable.
Is this all possible with simple abap FM Or need to use ABAPOO.
I will appericiate all expert help.
Many thanks in advance.
KDE.
Edited by: kde_test on Jun 4, 2010 5:44 PMHi,
Solutions :
1. You can use FM REUSE_ALV_HIERSEQ_LIST_DISPLAY as guided by Ashutosh.
You can also check out this
[http://www.sap technical.com/Tutorials/ABAP/3DGraph/demo.htm] change link to saptechnical without space
2. [How to make certain rows in ALV grid editable...;
3 & 4. Use two importing paramaters 'PF_STATUS_SET' 'USER_COMMAND' of REUSE_ALV_GRID_DISPLAY.
create two function codes 'CALC and 'SAVE' in pf-status and provide your required functionality to these function codes using User-Command.
Sorry am unable to provide you with supporting code, but you can search for it and It can solve your problem
Regards,
Rohit
Maybe you are looking for
-
I puchased cs6 for pc, now I want it for my new mac
Hi, I recently upgraded to macbook pro and want to install premiere cs6, but the software I purchases only works for Windows. How do I install on my mac? Thanks!
-
How to set password on mac air
how to set first password for mac air mike hawthorne
-
Webi Rich Client 2-tier Vs 3-tier?
Could anyone explain what is 2-tier and 3-tier for Rich Client? Thank you
-
Firefox will not open on my computer
From sometime last night to today (11/18) Firefox will not open when I click on the shortcut link from my desktop. I've tried to add another profile by clicking on start/run/firefox.exe but that doesn't even work. What would be the next step?
-
Lenovo service is not able to repair a X240 for 6 weeks now
For meanwhile 6 (!) weeks lenovo is not able to repair my X240. I never thought, that it would be so difficult to repair one of lenovos highend laptops with 3 years service and extended warrenty I have to mention, that this ist my 2nd X240. The firs