Joining VBRK, VBRP, VBAK, VBAP, LIKP, LIPS
Hello,
I just wanted to ask how to join the above subject in one table? Or it isnt possible?
I read that joining 3 or more tables would degrade the performance But i need to get the data in those tables. Any help would greatly appreciated. Thanks!
Hi,
Please take a look at my program below. There you can see how to join the tables that you mentioned. Hope it helps...
P.S. Please award points if it helps...
*=====================================================================
* Program Name : ZSD_ORDERSTAGE_V2
* Author : Aris Hidalgo
* Date Created : June 5, 2007
* Description : Display sales orders status for a given customer
*=====================================================================
REPORT zsd_orderstage_v2
NO STANDARD PAGE HEADING
MESSAGE-ID zsd.
* Data Dictionary Table/s *
TABLES: vbak,
vttp.
CLASS lcl_event_receiver DEFINITION DEFERRED.
* Global Data/s *
DATA: gt_fieldcat TYPE lvc_t_fcat,
ok_code TYPE syst-ucomm,
save_ok TYPE syst-ucomm,
g_repid TYPE syst-repid,
gs_layout TYPE lvc_s_layo,
gv_container TYPE scrfname VALUE 'CUSTOM_CONTROL',
grid1 TYPE REF TO cl_gui_alv_grid,
custom_container TYPE REF TO cl_gui_custom_container,
grid2 TYPE REF TO cl_gui_alv_grid,
dialogbox_container TYPE REF TO cl_gui_dialogbox_container,
event_receiver TYPE REF TO lcl_event_receiver.
* Global Structure/s *
TYPES: BEGIN OF t_output,
creation_date TYPE vbak-erdat,
creation_time TYPE vbak-erzet,
sales_doc TYPE vbak-vbeln,
cust_code TYPE vbak-kunnr,
cust_desc TYPE kna1-name1,
ship_to_code TYPE likp-kunnr,
ship_to_desc TYPE kna1-name1,
po_num TYPE vbak-bstnk,
doc_type TYPE vbak-auart,
req_dlv_date TYPE vbak-vdatu,
so_status(02) TYPE c,
created_by TYPE vbak-ernam,
del_doc TYPE likp-vbeln,
bill_doc TYPE vbrk-vbeln,
END OF t_output.
TYPES: BEGIN OF t_column,
fname TYPE lvc_fname,
level TYPE lvc_level,
END OF t_column.
* Global Internal Table/s *
DATA: gt_output TYPE STANDARD TABLE OF t_output,
gt_column TYPE STANDARD TABLE OF t_column.
* Global Work Area/s *
DATA: wa_output LIKE LINE OF gt_output.
* SELECTION-SCREEN *
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS: p_kunnr TYPE vbak-kunnr OBLIGATORY.
SELECT-OPTIONS: s_vkgrp FOR vbak-vkgrp,
s_auart FOR vbak-auart,
s_erdat FOR vbak-erdat OBLIGATORY,
s_ernam FOR vbak-ernam.
SELECTION-SCREEN END OF BLOCK b1.
*/ CLASS DEFINITION/S
CLASS lcl_process_data DEFINITION DEFERRED.
* CLASS lcl_get_data DEFINITION
CLASS lcl_get_data DEFINITION.
PUBLIC SECTION.
TYPES: BEGIN OF t_vbak,
vbeln TYPE vbak-vbeln,
erdat TYPE vbak-erdat,
erzet TYPE vbak-erzet,
ernam TYPE vbak-ernam,
auart TYPE vbak-auart,
vdatu TYPE vbak-vdatu,
bstnk TYPE vbak-bstnk,
kunnr TYPE vbak-kunnr,
END OF t_vbak.
TYPES: BEGIN OF t_kna1,
kunnr TYPE kna1-kunnr,
name1 TYPE kna1-name1,
END OF t_kna1.
TYPES: BEGIN OF t_delivery,
vgbel TYPE lips-vgbel,
vbeln TYPE likp-vbeln,
kunnr TYPE likp-kunnr,
END OF t_delivery.
TYPES: BEGIN OF t_billing,
vbelv TYPE vbfa-vbelv,
vbtyp_n TYPE vbfa-vbtyp_n,
vbeln TYPE vbfa-vbeln,
END OF t_billing.
TYPES: BEGIN OF t_status,
vbeln TYPE vbuk-vbeln, "Sales and Distribution Document Number
cmgst TYPE vbuk-cmgst, "Overall status of credit checks
lfstk TYPE vbuk-lfstk, "Delivery status
kostk TYPE vbuk-kostk, "Overall picking / putaway status
fkstk TYPE vbuk-fkstk, "Billing status
trsta TYPE vbuk-trsta, "Transportation planning status
END OF t_status.
TYPES: BEGIN OF t_status_do,
vbeln TYPE vbuk-vbeln, "Delivery Document Number
kostk TYPE vbuk-kostk, "Overall picking / putaway status
fkstk TYPE vbuk-fkstk, "Billing status
trsta TYPE vbuk-trsta, "Transportation planning status
END OF t_status_do.
METHODS: get_sales_docs FINAL,
get_customer_desc FINAL,
get_ship_to_desc FINAL,
get_delivery_docs FINAL,
get_billing_docs FINAL,
get_so_status FINAL.
PROTECTED SECTION.
CLASS-DATA: gt_vbak TYPE STANDARD TABLE OF t_vbak,
gt_kna1 TYPE HASHED TABLE OF t_kna1
WITH UNIQUE KEY kunnr,
gt_kna2 TYPE HASHED TABLE OF t_kna1
WITH UNIQUE KEY kunnr,
gt_delivery TYPE STANDARD TABLE OF t_delivery,
gt_billing TYPE STANDARD TABLE OF t_billing,
gt_status TYPE STANDARD TABLE OF t_status,
gt_status_do TYPE STANDARD TABLE OF t_status_do,
o_lcl_process_data TYPE REF TO lcl_process_data.
PRIVATE SECTION.
CLASS-DATA: wa_status LIKE LINE OF gt_status.
ENDCLASS. "lcl_get_data DEFINITION
* CLASS lcl_process_data DEFINITION
CLASS lcl_process_data DEFINITION INHERITING FROM lcl_get_data.
PUBLIC SECTION.
METHODS: combine_data FINAL
IMPORTING
im_sales_tab LIKE gt_vbak
im_cust_tab LIKE gt_kna1
im_desc_tab LIKE gt_kna2 OPTIONAL
im_dlv_tab LIKE gt_delivery OPTIONAL
im_bill_tab LIKE gt_billing OPTIONAL
EXPORTING
ex_output LIKE gt_output,
get_status
IMPORTING
im_so TYPE vbak-vbeln
im_do TYPE likp-vbeln OPTIONAL
EXPORTING
ex_status TYPE crmchar2.
PRIVATE SECTION.
DATA: lv_vbelv TYPE vbfa-vbelv,
lv_bill_doc TYPE vbfa-vbeln,
lv_kunnr TYPE vbpa-kunnr,
lv_name1 TYPE kna1-name1,
lv_parvw TYPE vbpa-parvw,
lv_flag1 TYPE flag.
ENDCLASS. "lcl_process_data DEFINITION
* CLASS lcl_alv_routines DEFINITION
CLASS lcl_alv_routines DEFINITION INHERITING FROM lcl_process_data.
PUBLIC SECTION.
TYPES: BEGIN OF t_status_history,
cr_hold(50) TYPE c,
cr_rel_on(10) TYPE c,
cr_rel_at(10) TYPE c,
do_created_on(10) TYPE c,
do_created_time(8) TYPE c,
picked_on(10) TYPE c,
picked_time(8) TYPE c,
inv_created_on(10) TYPE c,
dispatched_on(10) TYPE c,
dispatched_at(10) TYPE c,
END OF t_status_history.
TYPES: BEGIN OF t_confirmation,
podat TYPE likp-podat,
potim TYPE likp-potim,
END OF t_confirmation.
CLASS-DATA: wa_fieldcat LIKE LINE OF gt_fieldcat,
gt_status_history TYPE STANDARD TABLE OF t_status_history,
gt_confirmation TYPE STANDARD TABLE OF t_confirmation,
wa_status_history LIKE LINE OF gt_status_history,
wa_confirmation LIKE LINE OF gt_confirmation,
wa_column LIKE LINE OF gt_column,
gt_domain_val TYPE STANDARD TABLE OF dd07v,
wa_domain_val LIKE LINE OF gt_domain_val.
METHODS: build_fieldcat FINAL,
popup_routines
IMPORTING
im_column LIKE gt_column
im_output LIKE wa_output
EXPORTING
ex_status_history LIKE gt_status_history
ex_confirmation LIKE gt_confirmation,
get_domain_values FINAL
IMPORTING
value(im_tabname) TYPE ddobjname
value(im_fieldname) TYPE dfies-fieldname
EXPORTING
value(ex_values_tab) LIKE gt_domain_val.
PRIVATE SECTION.
CLASS-DATA: lt_dfies_tab TYPE STANDARD TABLE OF dfies,
wa_dfies_tab LIKE LINE OF lt_dfies_tab.
ENDCLASS. "lcl_alv_routines DEFINITION
* CLASS lcl_event_receiver DEFINITION
CLASS lcl_event_receiver DEFINITION INHERITING FROM lcl_alv_routines FINAL.
PUBLIC SECTION.
METHODS: handle_double_click
FOR EVENT double_click OF cl_gui_alv_grid
IMPORTING
e_row
e_column,
handle_close
FOR EVENT close OF cl_gui_dialogbox_container
IMPORTING
sender,
handle_hotspot_click
FOR EVENT hotspot_click OF cl_gui_alv_grid
IMPORTING
e_row_id
e_column_id
es_row_no,
create_detail_list
IMPORTING
im_column LIKE gt_column
im_status LIKE gt_status_history
im_confirmation LIKE gt_confirmation.
PRIVATE SECTION.
CLASS-DATA: o_lcl_alv_routines TYPE REF TO lcl_alv_routines.
ENDCLASS. "lcl_event_receiver DEFINITION
*/ CLASS IMPLEMENTATION/S
* CLASS lcl_get_data IMPLEMENTATION
CLASS lcl_get_data IMPLEMENTATION.
* METHOD get_sales_docs
METHOD get_sales_docs.
SELECT vbeln erdat erzet ernam auart vdatu bstnk kunnr
FROM vbak
INTO TABLE gt_vbak
WHERE erdat IN s_erdat
AND ernam IN s_ernam
AND auart IN s_auart
AND vkgrp IN s_vkgrp
AND kunnr = p_kunnr.
IF NOT gt_vbak[] IS INITIAL.
CALL METHOD: me->get_customer_desc,
get_delivery_docs,
get_so_status,
get_billing_docs.
CREATE OBJECT o_lcl_process_data.
CALL METHOD o_lcl_process_data->combine_data
EXPORTING
im_sales_tab = gt_vbak
im_cust_tab = gt_kna1
im_desc_tab = gt_kna2
im_dlv_tab = gt_delivery
im_bill_tab = gt_billing
IMPORTING
ex_output = gt_output.
ELSE.
MESSAGE i000 WITH text-032.
LEAVE LIST-PROCESSING.
ENDIF.
ENDMETHOD. "get_sales_docs
* METHOD get_customer_desc
METHOD get_customer_desc.
SELECT kunnr name1
FROM kna1
INTO TABLE gt_kna1
FOR ALL ENTRIES IN gt_vbak
WHERE kunnr = gt_vbak-kunnr.
ENDMETHOD. "get_customer_desc
* METHOD get_ship_to_desc
METHOD get_ship_to_desc.
SELECT kunnr name1
FROM kna1
INTO TABLE gt_kna2
FOR ALL ENTRIES IN gt_delivery
WHERE kunnr = gt_delivery-kunnr.
ENDMETHOD. "get_ship_to_desc
* METHOD get_delivery_docs
METHOD get_delivery_docs.
SELECT lips~vgbel likp~vbeln likp~kunnr
FROM likp
INNER JOIN lips
ON likp~vbeln = lips~vbeln
INTO TABLE gt_delivery
FOR ALL ENTRIES IN gt_vbak
WHERE lips~vgbel = gt_vbak-vbeln.
IF NOT gt_delivery[] IS INITIAL.
SORT gt_delivery ASCENDING BY: vgbel vbeln kunnr.
DELETE ADJACENT DUPLICATES FROM gt_delivery COMPARING vgbel vbeln kunnr.
* Get ship-to description
CALL METHOD me->get_ship_to_desc.
* Get status of delivery documents
SELECT vbeln kostk fkstk trsta
FROM vbuk
INTO TABLE gt_status_do
FOR ALL ENTRIES IN gt_delivery
WHERE vbeln = gt_delivery-vbeln.
ENDIF.
ENDMETHOD. "get_delivery_docs
* METHOD get_billing_docs
METHOD get_billing_docs.
SELECT vbelv vbtyp_n vbeln
FROM vbfa
INTO TABLE gt_billing
FOR ALL ENTRIES IN gt_delivery
WHERE vbelv = gt_delivery-vbeln
AND vbtyp_n = 'M'.
SORT gt_billing ASCENDING BY: vbelv vbtyp_n vbeln.
DELETE ADJACENT DUPLICATES FROM gt_billing COMPARING vbelv vbtyp_n vbeln.
ENDMETHOD. "get_billing_docs
* METHOD get_so_status
METHOD get_so_status.
DATA: lv_curr_so TYPE vbak-vbeln,
lv_lines TYPE i.
FIELD-SYMBOLS: <fs_status> LIKE LINE OF gt_status,
<fs_delivery> LIKE LINE OF gt_delivery,
<fs_status_do> LIKE LINE OF gt_status_do.
SELECT vbeln cmgst lfstk
FROM vbuk
INTO CORRESPONDING FIELDS OF TABLE gt_status
FOR ALL ENTRIES IN gt_vbak
WHERE vbeln = gt_vbak-vbeln.
SORT gt_status_do BY vbeln ASCENDING.
DESCRIBE TABLE gt_status LINES lv_lines.
LOOP AT gt_status ASSIGNING <fs_status>.
IF sy-tabix > lv_lines.
EXIT.
ENDIF.
LOOP AT gt_delivery ASSIGNING <fs_delivery> WHERE vgbel = <fs_status>-vbeln.
IF lv_curr_so = <fs_delivery>-vgbel.
wa_status-vbeln = <fs_status>-vbeln.
wa_status-cmgst = <fs_status>-cmgst.
wa_status-lfstk = <fs_status>-lfstk.
READ TABLE gt_status_do ASSIGNING <fs_status_do> WITH KEY vbeln = <fs_delivery>-vbeln
BINARY SEARCH.
IF sy-subrc = 0.
wa_status-kostk = <fs_status_do>-kostk.
wa_status-fkstk = <fs_status_do>-fkstk.
wa_status-trsta = <fs_status_do>-trsta.
ENDIF.
APPEND wa_status TO gt_status.
CLEAR wa_status.
ELSE.
READ TABLE gt_status_do ASSIGNING <fs_status_do> WITH KEY vbeln = <fs_delivery>-vbeln
BINARY SEARCH.
<fs_status>-kostk = <fs_status_do>-kostk.
<fs_status>-fkstk = <fs_status_do>-fkstk.
<fs_status>-trsta = <fs_status_do>-trsta.
ENDIF.
lv_curr_so = <fs_delivery>-vgbel.
ENDLOOP.
ENDLOOP.
ENDMETHOD. "get_do_status
ENDCLASS. "lcl_get_data IMPLEMENTATION
* CLASS lcl_process_data IMPLEMENTATION
CLASS lcl_process_data IMPLEMENTATION.
* METHOD combine_data
METHOD combine_data.
FIELD-SYMBOLS: <fs_sales_tab> LIKE LINE OF im_sales_tab,
<fs_cust_tab> LIKE LINE OF im_cust_tab,
<fs_desc_tab> LIKE LINE OF im_desc_tab,
<fs_dlv_tab> LIKE LINE OF im_dlv_tab,
<fs_bill_tab> LIKE LINE OF im_bill_tab.
SORT gt_status BY vbeln ASCENDING.
LOOP AT im_sales_tab ASSIGNING <fs_sales_tab>.
CLEAR: lv_flag1, wa_output,lv_vbelv,
lv_bill_doc, lv_kunnr,
lv_name1, lv_parvw.
wa_output-creation_date = <fs_sales_tab>-erdat. "SO creation date
wa_output-creation_time = <fs_sales_tab>-erzet. "SO creation time
wa_output-sales_doc = <fs_sales_tab>-vbeln. "Sales document
wa_output-cust_code = <fs_sales_tab>-kunnr. "SO customer code
* Customer description
READ TABLE im_cust_tab ASSIGNING <fs_cust_tab> WITH KEY kunnr = <fs_sales_tab>-kunnr.
IF sy-subrc = 0.
MOVE <fs_cust_tab>-name1 TO: wa_output-cust_desc. "SO customer description
ENDIF.
wa_output-po_num = <fs_sales_tab>-bstnk. "PO number
wa_output-doc_type = <fs_sales_tab>-auart. "SO document type
wa_output-req_dlv_date = <fs_sales_tab>-vdatu. "SO req. delivery date
wa_output-created_by = <fs_sales_tab>-ernam. "SO created by
READ TABLE im_dlv_tab ASSIGNING <fs_dlv_tab> WITH KEY vgbel = <fs_sales_tab>-vbeln.
IF sy-subrc <> 0.
CALL FUNCTION 'CONVERSION_EXIT_PARVW_INPUT'
EXPORTING
input = 'SH'
IMPORTING
output = lv_parvw.
*/Get ship-to party and description based from sales document
* if delivery document is non-existent
SELECT SINGLE kunnr
FROM vbpa
INTO lv_kunnr
WHERE vbeln = <fs_sales_tab>-vbeln
AND parvw = lv_parvw. "Ship-to party
IF sy-subrc = 0.
SELECT SINGLE name1
FROM kna1
INTO lv_name1
WHERE kunnr = lv_kunnr.
IF sy-subrc = 0.
wa_output-ship_to_code = lv_kunnr.
wa_output-ship_to_desc = lv_name1.
ENDIF.
ENDIF.
* Sales order status
CALL METHOD me->get_status
EXPORTING
im_so = wa_output-sales_doc
IMPORTING
ex_status = wa_output-so_status.
APPEND wa_output TO ex_output.
CLEAR wa_output.
CONTINUE.
ENDIF.
* Ship-to code/party and delivery document
LOOP AT im_dlv_tab ASSIGNING <fs_dlv_tab> WHERE vgbel = <fs_sales_tab>-vbeln.
CLEAR: lv_flag1.
wa_output-ship_to_code = <fs_dlv_tab>-kunnr. "Ship-to code
wa_output-del_doc = <fs_dlv_tab>-vbeln. "Delivery document
* Ship-to description
READ TABLE im_desc_tab ASSIGNING <fs_desc_tab> WITH KEY kunnr = <fs_dlv_tab>-kunnr.
IF sy-subrc = 0.
wa_output-ship_to_desc = <fs_desc_tab>-name1.
ENDIF.
* Sales order and delivery order status
CALL METHOD me->get_status
EXPORTING
im_so = wa_output-sales_doc
im_do = wa_output-del_doc
IMPORTING
ex_status = wa_output-so_status.
* Billing document
LOOP AT im_bill_tab ASSIGNING <fs_bill_tab> WHERE vbelv = <fs_dlv_tab>-vbeln
AND vbtyp_n = 'M'.
CLEAR lv_flag1.
IF lv_vbelv = <fs_bill_tab>-vbelv AND
lv_bill_doc = <fs_bill_tab>-vbeln.
CONTINUE.
ENDIF.
lv_vbelv = <fs_bill_tab>-vbelv.
lv_bill_doc = <fs_bill_tab>-vbeln.
wa_output-bill_doc = <fs_bill_tab>-vbeln. "Billing document
MOVE 'X' TO lv_flag1.
APPEND wa_output TO ex_output.
CLEAR: wa_output-ship_to_code, wa_output-del_doc,
wa_output-so_status, wa_output-bill_doc.
EXIT.
ENDLOOP.
IF lv_flag1 = 'X'.
CONTINUE.
ELSE.
APPEND wa_output TO ex_output.
CLEAR: wa_output-ship_to_code, wa_output-del_doc,
wa_output-ship_to_desc, wa_output-so_status.
ENDIF.
ENDLOOP.
ENDLOOP.
SORT ex_output BY sales_doc.
ENDMETHOD. "combine_data
* METHOD get_status
METHOD get_status.
FIELD-SYMBOLS: <fs_status> LIKE LINE OF gt_status,
<fs_status_do> LIKE LINE OF gt_status_do.
*/Check the current stage of a given sales order in descending order
* starting with the shipment status
READ TABLE gt_status_do ASSIGNING <fs_status_do> WITH KEY vbeln = im_do
BINARY SEARCH.
IF sy-subrc = 0.
* Shipment/dispatch status
IF <fs_status_do>-trsta = 'B' OR
<fs_status_do>-trsta = 'C'.
ex_status = 'SH'.
* Invoice status
ELSEIF <fs_status_do>-fkstk = 'B' OR
<fs_status_do>-fkstk = 'C'.
ex_status = 'IN'.
* Picking status
ELSEIF <fs_status_do>-kostk = 'B' OR
<fs_status_do>-kostk = 'C'.
ex_status = 'PS'.
ENDIF.
ENDIF.
IF ex_status IS INITIAL.
READ TABLE gt_status ASSIGNING <fs_status> WITH KEY vbeln = im_so
BINARY SEARCH.
IF sy-subrc = 0.
* Delivery order status
IF <fs_status>-lfstk = 'B' OR
<fs_status>-lfstk = 'C'.
ex_status = 'DO'.
* Credit released
ELSEIF <fs_status>-cmgst = 'A' OR
<fs_status>-cmgst = 'D'.
ex_status = 'CR'.
* Credit hold
ELSEIF <fs_status>-cmgst = 'B' OR
<fs_status>-cmgst = 'C'.
ex_status = 'CH'.
ENDIF.
ENDIF.
ENDIF.
ENDMETHOD. "get_status
ENDCLASS. "lcl_process_data IMPLEMENTATION
* CLASS lcl_alv_routines IMPLEMENTATION
CLASS lcl_alv_routines IMPLEMENTATION.
* METHOD build_fieldcat
METHOD build_fieldcat.
REFRESH: gt_fieldcat.
CLEAR wa_fieldcat.
DEFINE m_fieldcat.
add 1 to wa_fieldcat-col_pos.
wa_fieldcat-fieldname = &1.
wa_fieldcat-tabname = &2.
wa_fieldcat-coltext = &3.
wa_fieldcat-outputlen = &4.
wa_fieldcat-fix_column = &5.
wa_fieldcat-just = &6.
wa_fieldcat-do_sum = &7.
wa_fieldcat-emphasize = &8.
wa_fieldcat-hotspot = &9.
append wa_fieldcat to gt_fieldcat.
END-OF-DEFINITION.
IF wa_column-fname = 'SO_STATUS'.
m_fieldcat 'CR_HOLD' 'GT_STATUS_HISTORY' text-002 '50' 'X' '' '' '' ''.
m_fieldcat 'CR_REL_ON' 'GT_STATUS_HISTORY' text-003 '18' 'X' '' '' '' ''.
m_fieldcat 'CR_REL_AT' 'GT_STATUS_HISTORY' text-004 '18' 'X' '' '' '' ''.
m_fieldcat 'DO_CREATED_ON' 'GT_STATUS_HISTORY' text-005 '13' 'X' '' '' '' ''.
m_fieldcat 'DO_CREATED_TIME' 'GT_STATUS_HISTORY' text-030 '15' 'X' '' '' '' ''.
m_fieldcat 'PICKED_ON' 'GT_STATUS_HISTORY' text-006 '12' 'X' '' '' '' ''.
m_fieldcat 'PICKED_TIME' 'GT_STATUS_HISTORY' text-031 '12' 'X' '' '' '' ''.
m_fieldcat 'INV_CREATED_ON' 'GT_STATUS_HISTORY' text-007 '15' 'X' '' '' '' ''.
m_fieldcat 'DISPATCHED_ON' 'GT_STATUS_HISTORY' text-008 '13' 'X' '' '' '' ''.
m_fieldcat 'DISPATCHED_AT' 'GT_STATUS_HISTORY' text-009 '13' 'X' '' '' '' ''.
ELSEIF wa_column-fname = 'BILL_DOC'.
m_fieldcat 'PODAT' 'GT_CONFIRMATION' text-010 '17' 'X' '' '' '' ''.
m_fieldcat 'POTIM' 'GT_CONFIRMATION' text-011 '17' 'X' '' '' '' ''.
ELSE.
m_fieldcat 'CREATION_DATE' 'GT_OUTPUT' text-012 '10' 'X' '' '' '' ''.
m_fieldcat 'CREATION_TIME' 'GT_OUTPUT' text-013 '10' 'X' '' '' '' ''.
m_fieldcat 'SALES_DOC' 'GT_OUTPUT' text-014 '10' 'X' '' '' 'X' 'X'.
m_fieldcat 'CUST_CODE' 'GT_OUTPUT' text-015 '16' 'X' '' '' '' ''.
m_fieldcat 'CUST_DESC' 'GT_OUTPUT' text-016 '40' 'X' '' '' '' ''.
m_fieldcat 'SHIP_TO_CODE' 'GT_OUTPUT' text-017 '15' 'X' '' '' '' ''.
m_fieldcat 'SHIP_TO_DESC' 'GT_OUTPUT' text-018 '40' 'X' '' '' '' ''.
m_fieldcat 'PO_NUM' 'GT_OUTPUT' text-019 '24' 'X' '' '' '' ''.
m_fieldcat 'DOC_TYPE' 'GT_OUTPUT' text-020 '16' 'X' '' '' '' ''.
m_fieldcat 'REQ_DLV_DATE' 'GT_OUTPUT' text-021 '21' 'X' '' '' '' ''.
m_fieldcat 'SO_STATUS' 'GT_OUTPUT' text-022 '09' 'X' '' '' 'C400' ''.
m_fieldcat 'CREATED_BY' 'GT_OUTPUT' text-023 '13' 'X' '' '' '' ''.
m_fieldcat 'DEL_DOC' 'GT_OUTPUT' text-024 '18' 'X' '' '' '' ''.
m_fieldcat 'BILL_DOC' 'GT_OUTPUT' text-025 '11' 'X' '' '' 'C600' ''.
ENDIF.
ENDMETHOD. "build_fieldcat
* METHOD popup_routines
METHOD popup_routines.
READ TABLE im_column INDEX 1 INTO wa_column.
FIELD-SYMBOLS: <fs_status> LIKE LINE OF gt_status.
DATA: lv_datum TYPE syst-datum,
lv_uzeit TYPE syst-uzeit.
CLEAR: wa_status_history, lv_datum, lv_uzeit.
REFRESH gt_status_history.
*/Popup routine if user clicked on the SO status
IF wa_column-fname = 'SO_STATUS'.
CALL METHOD me->get_domain_values
EXPORTING
im_tabname = 'VBUK'
im_fieldname = 'CMGST'
IMPORTING
ex_values_tab = gt_domain_val.
* Credit hold
READ TABLE gt_status ASSIGNING <fs_status> WITH KEY vbeln = im_output-sales_doc.
IF sy-subrc = 0.
wa_status_history-cr_hold = <fs_status>-cmgst.
ENDIF.
READ TABLE gt_domain_val INTO wa_domain_val WITH
KEY domvalue_l = wa_status_history-cr_hold
TRANSPORTING ddtext.
IF sy-subrc = 0.
wa_status_history-cr_hold = wa_domain_val-ddtext.
ENDIF.
* Credit released date and time
SELECT SINGLE udate utime
FROM cdhdr
INTO (lv_datum, lv_uzeit)
WHERE objectid = im_output-sales_doc
AND tcode = 'VKM3'.
IF sy-subrc = 0.
WRITE lv_datum TO wa_status_history-cr_rel_on
USING EDIT MASK '__/__/____'.
CLEAR lv_datum.
WRITE lv_uzeit TO wa_status_history-cr_rel_at
USING EDIT MASK '__:__:__'.
CLEAR lv_uzeit.
ENDIF.
* DO creation date and time
IF NOT im_output-del_doc IS INITIAL.
SELECT SINGLE erdat erzet
FROM likp
INTO (lv_datum, lv_uzeit)
WHERE vbeln = im_output-del_doc.
IF sy-subrc = 0.
WRITE lv_datum TO wa_status_history-do_created_on
USING EDIT MASK '__/__/____'.
CLEAR lv_datum.
WRITE lv_uzeit TO wa_status_history-do_created_time
USING EDIT MASK '__:__:__'.
CLEAR lv_uzeit.
ENDIF.
* Picking date and time
SELECT SINGLE bdatu bzeit
FROM ltak
INTO (lv_datum, lv_uzeit)
WHERE vbeln = im_output-del_doc.
IF sy-subrc = 0.
WRITE lv_datum TO wa_status_history-picked_on
USING EDIT MASK '__/__/____'.
CLEAR lv_datum.
WRITE lv_uzeit TO wa_status_history-picked_time
USING EDIT MASK '__:__:__'.
CLEAR lv_uzeit.
ENDIF.
ENDIF.
* Invoice created on
SELECT SINGLE erdat
FROM vbrk
INTO lv_datum
WHERE vbeln = im_output-bill_doc.
WRITE lv_datum TO wa_status_history-inv_created_on
USING EDIT MASK '__/__/____'.
CLEAR lv_datum.
* Dispatched on and dispatched at
SELECT SINGLE tknum
FROM vttp
INTO vttp-tknum
WHERE vbeln = im_output-del_doc.
IF sy-subrc = 0.
SELECT SINGLE dtabf uzabf
FROM vttk
INTO (lv_datum, lv_uzeit)
WHERE tknum = vttp-tknum.
WRITE lv_datum TO wa_status_history-dispatched_on
USING EDIT MASK '__/__/____'.
CLEAR lv_datum.
WRITE lv_uzeit TO wa_status_history-dispatched_at
USING EDIT MASK '__:__:__'.
CLEAR lv_uzeit.
ENDIF.
APPEND wa_status_history TO gt_status_history.
ex_status_history[] = gt_status_history[].
CLEAR wa_status_history.
*/Popup routine if the user clicked on the billing document
ELSEIF wa_column-fname = 'BILL_DOC'.
IF NOT im_output-del_doc IS INITIAL.
SELECT SINGLE podat potim
FROM likp
INTO (wa_confirmation-podat, wa_confirmation-potim)
WHERE vbeln = im_output-del_doc.
APPEND wa_confirmation TO gt_confirmation.
ex_confirmation[] = gt_confirmation[].
CLEAR wa_confirmation.
ENDIF.
ENDIF.
ENDMETHOD. "popup_routines
* METHOD get_domain_values
METHOD get_domain_values.
CALL FUNCTION 'DDIF_FIELDINFO_GET'
EXPORTING
tabname = im_tabname
fieldname = im_fieldname
langu = sy-langu
* LFIELDNAME = ' '
* ALL_TYPES = ' '
* GROUP_NAMES = ' '
* UCLEN =
* IMPORTING
* X030L_WA =
* DDOBJTYPE =
* DFIES_WA =
* LINES_DESCR =
TABLES
dfies_tab = lt_dfies_tab
* FIXED_VALUES =
* EXCEPTIONS
* NOT_FOUND = 1
* INTERNAL_ERROR = 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.
READ TABLE lt_dfies_tab INDEX 1 INTO wa_dfies_tab
TRANSPORTING domname.
CALL FUNCTION 'GET_DOMAIN_VALUES'
EXPORTING
domname = wa_dfies_tab-domname
* TEXT = 'X'
* FILL_DD07L_TAB = ' '
TABLES
values_tab = ex_values_tab
* VALUES_DD07L =
* EXCEPTIONS
* NO_VALUES_FOUND = 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.
ENDMETHOD. "get_domain_values
ENDCLASS. "lcl_alv_routines IMPLEMENTATION
* CLASS lcl_event_receiver IMPLEMENTATION
CLASS lcl_event_receiver IMPLEMENTATION.
* METHOD handle_double_click
METHOD handle_double_click.
IF e_column = 'SO_STATUS' OR
e_column = 'BILL_DOC'.
CREATE OBJECT: o_lcl_alv_routines.
CLEAR: wa_output.
REFRESH: gt_fieldcat,
gt_column,
gt_status_history,
gt_confirmation.
MOVE: e_column-fieldname TO wa_column-fname,
e_column-hierlevel TO wa_column-level.
APPEND wa_column TO gt_column.
* Get record based on what the user clicked
READ TABLE gt_output INDEX e_row-index INTO wa_output.
* Build fieldcatalog depending on what the user clicked
CALL METHOD o_lcl_alv_routines->build_fieldcat.
* Call popup routine/s
CALL METHOD o_lcl_alv_routines->popup_routines
EXPORTING
im_column = gt_column
im_output = wa_output
IMPORTING
ex_status_history = gt_status_history
ex_confirmation = gt_confirmation.
CALL METHOD me->create_detail_list
EXPORTING
im_column = gt_column
im_status = gt_status_history
im_confirmation = gt_confirmation.
ENDIF.
ENDMETHOD. "handle_double_click
* METHOD handle_close
METHOD handle_close.
CALL METHOD sender->set_visible
EXPORTING
visible = space.
ENDMETHOD. "handle_close
* METHOD handle_hotspot_click
METHOD handle_hotspot_click.
READ TABLE gt_output INDEX e_row_id INTO wa_output.
IF NOT wa_output-sales_doc IS INITIAL
AND e_column_id = 'SALES_DOC'.
SET PARAMETER ID 'AUN' FIELD wa_output-sales_doc.
CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.
ENDIF.
ENDMETHOD. "handle_hotspot_click
* METHOD create_detail_list
METHOD create_detail_list.
DATA: lv_caption(200) TYPE c.
CLEAR wa_column.
* Create popup window
CREATE OBJECT dialogbox_container
EXPORTING
top = 100
left = 150
lifetime = cntl_lifetime_dynpro
caption = lv_caption
width = 800
height = 200.
CREATE OBJECT grid2
EXPORTING i_parent = dialogbox_container.
* Trigger event when user closes the popup window
SET HANDLER event_receiver->handle_close FOR dialogbox_container.
READ TABLE im_column INDEX 1 INTO wa_column.
* Display popup window
IF wa_column-fname = 'SO_STATUS'.
gs_layout-grid_title = text-026.
CALL METHOD grid2->set_table_for_first_display
EXPORTING
* i_structure_name = 'T_OUTPUT'
is_layout = gs_layout
CHANGING
it_outtab = gt_status_history
it_fieldcatalog = gt_fieldcat.
ELSEIF wa_column-fname = 'BILL_DOC'.
gs_layout-grid_title = text-027.
CALL METHOD grid2->set_table_for_first_display
EXPORTING
* i_structure_name = 'T_OUTPUT'
is_layout = gs_layout
CHANGING
it_outtab = gt_confirmation
it_fieldcatalog = gt_fieldcat.
ENDIF.
CALL METHOD cl_gui_control=>set_focus
EXPORTING
control = grid2.
ENDMETHOD. "create_detail_list
ENDCLASS. "lcl_event_receiver IMPLEMENTATION
* START-OF-SELECTION *
START-OF-SELECTION.
DATA: o_lcl_get_data TYPE REF TO lcl_get_data.
CREATE OBJECT o_lcl_get_data.
CALL METHOD o_lcl_get_data->get_sales_docs.
* END-OF-SELECTION *
END-OF-SELECTION.
CALL SCREEN 100.
*& Module STATUS_0100 OUTPUT
* text
MODULE status_0100 OUTPUT.
SET PF-STATUS '100'.
SET TITLEBAR 'TITLE100'.
DATA: o_lcl_alv_routines TYPE REF TO lcl_alv_routines,
gv_text TYPE string,
gv_name1 TYPE kna1-name1,
gv_date_low(10) TYPE c,
gv_date_high(10) TYPE c.
CREATE OBJECT o_lcl_alv_routines.
g_repid = sy-repid.
IF custom_container IS INITIAL.
CREATE OBJECT custom_container
EXPORTING
container_name = gv_container
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5.
IF sy-subrc NE 0.
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = g_repid
txt2 = sy-subrc
txt1 = text-028.
ENDIF.
CREATE OBJECT grid1
EXPORTING
i_parent = custom_container.
* Build fieldcatalog for initial display
CALL METHOD o_lcl_alv_routines->build_fieldcat.
SELECT SINGLE name1
FROM kna1
INTO gv_name1
WHERE kunnr = p_kunnr.
WRITE: s_erdat-low TO gv_date_low USING EDIT MASK '__/__/____',
s_erdat-high TO gv_date_high USING EDIT MASK '__/__/____'.
CONCATENATE: gv_name1 'from:' gv_date_low '-' gv_date_high
INTO gv_text
SEPARATED BY space.
gs_layout-grid_title = gv_text.
* Display initial window
CALL METHOD grid1->set_table_for_first_display
EXPORTING
* i_structure_name = ''
is_layout = gs_layout
CHANGING
it_outtab = gt_output
it_fieldcatalog = gt_fieldcat.
CREATE OBJECT event_receiver.
* Trigger event when user double clicks initial window
SET HANDLER event_receiver->handle_double_click FOR grid1.
* Trigger event when user clicks hotspot field
SET HANDLER event_receiver->handle_hotspot_click FOR grid1.
ENDIF.
CALL METHOD cl_gui_control=>set_focus
EXPORTING
control = grid1.
ENDMODULE. " STATUS_0100 OUTPUT
*& Module USER_COMMAND_0100 INPUT
* text
MODULE user_command_0100 INPUT.
save_ok = ok_code.
CASE save_ok.
WHEN 'BACK' OR 'EXIT' OR 'CANCEL'.
CALL METHOD custom_container->free.
CALL METHOD cl_gui_cfw=>flush.
IF sy-subrc <> 0.
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = g_repid
txt2 = sy-subrc
txt1 = text-029.
ENDIF.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
Similar Messages
-
Vbrk..vbak..likp..vttk
experts question...
could you tell me how would I connect vbak in vbrk then likp then vttk...i dont know how would I connect them in my where clause and which field do I need to select.
I need to show all these fields:
in vbak i need the vbeln , auart
vbrk i need the vbeln , fkdat
likp i need the vbeln , erdat
vttk i need the tknum , erdat
in my selection-screen all vbeln of vbak , vbrk , likp and vttk.
please help me or give me materials on how would I connect each table.many thanks
<REMOVED BY MODERATOR>
Edited by: Alvaro Tejada Galindo on Apr 14, 2008 5:28 PMstrep1: first join the vbak and vbrk based on vbeln
like:
FROM vbak AS a INNER JOIN vbrp AS b
ON avbeln = bvbeln
step 2:
Pass the vbeln field in where condtion to fetch the data( vbeln , erdat) from likp
***selection from likp
INTO TABLE t_likp
FOR ALL ENTRIES IN lt_vbak_vbrk
WHERE vbeln = lt_vbak_vbrk-vgbel AND
posnr = lt_vbak_vbrk-vgpos .
step3:here you need pass this vbeln field to vttp table to get the tknum because there is no vbeln field in directly in vttk table so first we pass this vbeln value in vttp table then from vttk
IF NOT t_likp[] IS INITIAL .
SELECT tknum
FROM vttp
INTO TABLE t_vttp
FOR ALL ENTRIES IN t_likp
WHERE vbeln = t_likp-vbeln .
***SELECTING from vttk table
IF NOT t_vttp IS INITIAL .
SELECT tknum
erdat
tdlnr
FROM vttk
INTO TABLE t_vttk
FOR ALL ENTRIES IN t_vttp
WHERE tknum = t_vttp-tknum .
use the above steps and it'll work for you. -
JOIN VBRK VBRP : BAD performance
I have a big performance problem with this :
SELECT vvbeln vfkart vfkdat vvbtyp vkunrg vvkorg v~bukrs
bPOSNR bmatnr bfkimg bprsdt b~werks
FROM VBRK As v
JOIN VBRP AS b ON bvbeln = vvbeln
APPENDING corresponding fields of table t_vbrk
WHERE v~fkart IN s_fkart
AND b~matnr IN s_matnr
AND b~ean11 IN s_ean11.
Any idea to solve this issue to improve the perfromance ?
Thank you.HI
Use for all entries instead of joins and remove corresponding fields of, use into table with exact strucutre fields. -
How to Join VBRK, VBRP and BSEG
Dear Guys
I have Billing No from VBRP/VBRK and want to join these tables with BSEG to pick Accounting Doc No.
How to Join these tables.
ThanksHi,
What you can do is to use FM AC_DOCUMENT_RECORD. Please check my example below:
MOVE: 'VBRK' TO lv_awtyp,
wa_vbrk-vbeln TO lv_awref,
'2007' TO lv_aworg.
CALL FUNCTION 'AC_DOCUMENT_RECORD'
EXPORTING
i_awtyp = lv_awtyp
i_awref = lv_awref
i_aworg = lv_aworg
* I_AWSYS = ' '
* I_AWTYP_INCL = ' '
* I_AWTYP_EXCL = ' '
* I_BUKRS = ' '
* I_VALUTYP = '0'
x_dialog = ''
TABLES
t_documents = lt_documents
EXCEPTIONS
no_reference = 1
no_document = 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.
Hope it helps...
P.S. Please award points if it helps... -
Join Problem LIKP,LIPS,VBRK and VBRP
Hi,
i am working on the SAP Query report. But having problem in creating joins between the following tables
LIKP
LIPS
VBRK
VBRP
please guide me
regard
khurramLIKP
LIPS
VBRK
VBRP
select a~ b~ c~ d~ into corresponding fields of table itab from likp as a inner join
LIPS as b on a~VBELN = b~VBELN
VBRK as c~VBELN = a~VBELN
VBRP as d~VBELN = a~~VBELN.
also check the first condition a~VBELN = b~(KDAUF,VBELV,VGBEL,WKTNR)
second condition a~VBELN = c~SFAKN
third condition a~VBELN = d~(AUBEL,VBELV,VGBEL,VGBEL_EX)
hope it solves... -
Performance issue with joins on table VBAK, VBEP, VBKD and VBAP
hi all,
i have a report where there is a join on all 4 tables VBAK, VBEP, VBKD and VBAP.
the report is giving performance issues because of this join.
all the key fields are used for the joining of tables. but some of the non-key fields like vbap-vstel, vbap-abgru and vbep-wadat are also part of select query and are getting filled.
because of these there is a performance issue.
is there any way i can improve the performance of the join select query?
i am trying "for all entries" clause...
kindly provide any alternative if possible.
thanks.Hi,
Pls perform some of the below steps as applicable for the performance improvement:
a) Remove join on all the tables and put joins only on header and item (VBAK & VBAP).
b) code should have separate select for VBEP and VBKD.
c) remove the non key fields from the where clause. Once you retrieve data from the database into the internal table, sort the table and delete the entries which are not part of the non-key fields like vstel, abgru and wadat.
d) last option is you can create index in the VBAP & VBEP table with respect to the fields vstel, abgru & wadat ( not advisable)
e) buffering option on database tables also possible.
f) select only the fields into the internal table that are applicable for the processing logic and also the select query should contaian the field names in the same order as mentioned in the database table.
Hope this helps.
Regards
JLN -
I want to join the table vbrk,vbrp,konv and fields are vbeln, knumv.
i want to join the table vbrk,vbrp,konv and fields are vbeln, knumv is possible .
if it isn't possible. what is the another method output is doc. no.(vbrp-vbeln) condition doc. no.(vbrk-knumv) , condition(konv-kschl), tax rate(konv-mwsk1), quantitty(vbrp-fkimg) .reply pls... as soon as possible..Hi..
This is the Join :
SELECT VBAKVBELN VBRKKNUMV
VBRP~FKIMG
KONV-KSCHL KONV~MWSK`
FROM VBRK
INNER JOIN VBRP
ON VBRKVBELN = VBRPVBELN
INNER JOIN KONV
ON KONVKNUMV = VBRKKNUMV
INTO TABLE <ITAB>
WHERE <CONDITION>.
REWARD IF HELPFUL. -
I want to join the table vbrk,vbrp,konv but konv is cluster table .
Hi
konv is the cluster table . so I want to join the table vbrk,vbrp,konv and fields are vbeln, knumv is possible .
if it isn't possible. what is the another method output is doc. no.(vbrp-vbeln) condition doc. no.(vbrk-knumv) , condition(konv-kschl), tax rate(konv-mwsk1), quantitty(vbrp-fkimg) .reply pls... as soon as possible..hi
good
1) Open
Select
Mard~matnr
Makt~maktx
From Makt
Inner Join Mard
on Maktmatnr = Mardmatnr
Where Makt~Spras = SY-LANGU
2) Native Oracle
SELECT Mard.matnr,
Makt.maktx
From Makt, Mard
Where Makt.mandt = Mard.mandt
And Makt.matnr = Mard.matnr
And Makt.mandt = :SY-MANDT
And Makt.spras = :SY-LANGU
3) KONV is Cluster - BAD LUCK!
Select VBRK~VBELN
VBRP~POSNR
KONV~KSCHL
KONV~KWERT
From ( VBRK Inner Join VBRP
On VBRKVBELN = VBRPVBELN )
Inner Join KONV
On VBRKKNUMV = KONVKNUMV
And VBRPPOSNR = KONVKPOSN
4) KONV is Cluster - BAD LUCK!
Select KONV~KNUMV
KONV~KPOSN
KONV~KSCHL
KONV~KWERT
From KONV
Where KONV~KNUMV in (
Select VBRK~KNUMV
From VBRK Inner Join VBRP
On VBRKVBELN = VBRPVBELN
Where VBRKKNUMV = KONVKNUMV
And VBRPPOSNR = KONVKPOSN
5) Open
Select VBRP~MATNR
Sum( VBRP~NETWR )
From VBRP
Group By VBRP~MATNR
6) Native Oracle
Select VBRP.MATNR ,
Sum( VBRP.NETWR )
From VBRP
Where mandt = :sy-mandt
Group By VBRP.MATNR
7) Native Oracle
Select VBRP.MATNR ,
Count( VBRP.NETWR ),
Sum( VBRP.NETWR )
From VBRP
Where mandt = :sy-mandt
Group By VBRP.MATNR
8) Open
Select VBRP~MATNR
makt~maktx
Sum( VBRP~NETWR )
From VBRP inner Join MAKT
On VBRPMATNR = MAKTMATNR
Where MAKT~SPRAS = SY-LANGU
Group By VBRPMATNR maktmaktx
9) Native Oracle
Select VBRP.MANDT,
VBRP.MATNR,
MAKT.MAKTX,
Sum( VBRP.NETWR )
From VBRP , MAKT
Where VBRP.MANDT = MAKT.MANDT
And VBRP.MATNR = MAKT.MATNR
And MAKT.SPRAS = :SY-LANGU
Group By VBRP.MANDT, VBRP.MATNR, MAKT.MAKTX
10) Open
SELECT EKET~EBELN
EKET~EINDT
EKET~WAMNG
EKET~WEMNG
From ( ekko INNER JOIN ekpo
ON ekkomandt = ekpomandt
AND ekkoebeln = ekpoebeln
INNER JOIN eket
ON ekpomandt = eketmandt
AND ekpoebeln = eketebeln
AND ekpoebelp = eketebelp
AND EKET~WAMNG > 0
AND EKETWAMNG <> EKETWEMNG
Where EKPO~MATNR = 'NB220'
And EKPO~WERKS In ('P001', 'P004', 'L004')
And EKKO~BSTYP = 'F'
And EKKO~BSART = 'UB'
And EKPO~ELIKZ <> 'X'
And EKKO~LOEKZ <> 'X'
11) Native Oracle
SELECT EKET.EBELN,
EKET.EINDT,
EKET.WAMNG,
EKET.WEMNG
FROM ( ekko INNER JOIN ekpo
ON ekko.mandt = ekpo.mandt
AND ekko.ebeln = ekpo.ebeln
INNER JOIN eket
ON ekpo.mandt = eket.mandt
AND ekpo.ebeln = eket.ebeln
AND ekpo.ebelp = eket.ebelp
AND EKET.WAMNG > 0
AND EKET.WAMNG <> EKET.WEMNG
Where EKPO.MATNR = 'NB220'
And EKPO.WERKS In ('P001', 'P004', 'L004')
And EKKO.BSTYP = 'F'
And EKKO.BSART = 'UB'
And EKPO.ELIKZ <> 'X'
And EKKO.LOEKZ <> 'X'
thanks
mrutyun^ -
Reg:VBFA linking VBRK and VBAK
Hi All,
I am fetching vbrk, vbrp data. Now, i need to fetch data from vbak and vbap. i have passed the vbeln from vbrk to vbfa-vbeln and finally passed the vbelv value to vbak to get data from it. Is it the correct way?
Regards,
SwathiHi
U can find the link between VBRK and VBAK without to use VBFA table, this improves the performance of the program:
SELECT SINGLE * FROM VBRK WHERE VBELN = P_VBELN.
WRITE: 'Nr. bill:', VBRK-VBELN.
SELECT * FROM VBRP WHERE VBELN = VBRK-VBELN.
WRITE: / 'Nr. item:', VBRP-POSNR,
'Sales Order:', VBRP-AUBEL,
'Sales Order Item:', VBRP-AUPOS.
ENDSELECT.
So you can read the link in VBRP table.
If you want to read the VBFA
VBFA-VBELN = VBRK-VBELN.
VBFA-VBTYP_V = 'C'.
In this way you should select all records linked to the order, u find the number in VBFA-VBELV.
But you can also use fm RV_ORDER_FLOW_INFORMATION
Max -
How to create analytic view with tables VBRK VBRP KONV ?
Hi Gurus,
What is the best way to combine in a analytic view tables VBRK VBRP and KONV for better optimization or
how to make the relationship tables VBRK VBRP KONV with better performance in Hana Studio ?
This analytic view should be used in a calculation view to the final calculations.
Thanks !Hi Rogerio,
Greetings.
Basically , when you design your analytic views , while designing your data foundation , you can directly join the tables with the corresponding key attributes . Analytic views are capable of optimizing the join operation when we access the view.Logic of joining is purely depends on your business requirement
Sreehari. -
Is there any VIEW or FM for pulling data from VBAK, VBAP?also for VBEP,VBBE
Hi Experts,
1) Instaed of using JOINS and FOR ALL ENTRIES, am looking to use any view or FM for pullinmg the data from, VBAK & VBAP,
So, pls let me knwo that, Is there any VIEW or FM for pulling the data from the above of tables
2) Instaed of using JOINS and FOR ALL ENTRIES, am looking to use any view or FM for pullinmg the data from, VBEP & VBBE,
So, pls let me knwo that, Is there any VIEW or FM for pulling the data from the above of tables
3) Am guessing FOR ALL ENTRIES is better than JOINS in PERFORMENCE perspective, Is am I correct?
thanq
Edited by: Srinivas on May 9, 2008 5:36 PMHi Srinivas,
You can use the view WB2_V_VBAK_VBAP2 for fetching data from VBAK and VBAP instead of using a JOIN. Note that, in the view, item data fields will have a I following the field name (POSNRI, MATNR_I are the item data fields from VBAP). The master data fields of VBAK are the same.
As far as i know, there are no standard views provided by SAP for VBEP and VBBE. Not sure if FM exists either.
While using FOR ALL ENTRIES clause make sure that you specify the entire primary key (EX. if selecting from VBAP specify VBELN and POSNR) as fields for selection or in the selection criteria. Its much better if you have the primary key in both. This is really important because without specifying the entire key and using FOR ALL ENTRIES will drastically bring down the performance. And also, If you are fetching not more than 100 or 200 entries using the clause it is fine, beyond that its same as using a select statement within LOOP...ENDLOOP.
So, you have to decide whether to use FOR ALL ENTRIES or a JOIN while selecting data depending on the requirement. If you don't have the entire key either in fields for selection or selection criteria, then its better to use a JOIN or VIEW.
The following is an example for using FOR ALL ENTRIES clause effectively.
Select VBELN
POSNR
MATNR
From VBAP
into Table T_VBAP
For All Entries in T_DATA
Where VBELN eq T_DATA-VBELN
And POSNR eq T_DATA-POSNR.
I hope this helps, Please let me know if you need further assistance. -
Join of thre tables - index VLPMA, LIPS, VBUP
Hello,
I woud like to ask you about help. I have to do performance tuning of one program wich runs very long. I noticed, that the biggest problem is in join of three tables LIKP, LIPS and VBUP. I replaced original table LIKP by index table VLPMA and it helped - mainly when a material is filled in on select-option s_matnr. But the run is still very long. DO you have any idea what more could I do with the select? Ist there any index table similar to lips?
select lipslgort vlpmavbeln vlpmaposnr vlpmamatnr vlpma~kunnr
lipslgmng lipsmeins into table ilips
from vlpma inner join vbup on vbupvbeln eq vlpmavbeln and
vbupposnr eq vlpmaposnr
inner join lips on vlpmavbeln eq lipsvbeln and
vlpmaposnr eq lipsposnr
where vlpma~matnr in s_matnr and
lips~lgort in s_lgort and
vbup~wbsta ne 'C' and
vbup~kosta ne 'C' .
Thanks a lot
Miloslav PudilSince VBUP is not in the list of selected fields, it doesn't need to be included in the join. Instead, it can be in an EXISTS subquery in the WHERE clause. This is logically the same but the join is on two tables only. Also incorporating the other idea from Dave L. of not using NOT should help further.
select lips~lgort vlpma~vbeln vlpma~posnr vlpma~matnr vlpma~kunnr lips~lgmng lips~meins
into table ilips
from vlpma
inner join lips on vlpma~vbeln eq lips~vbeln and vlpma~posnr eq lips~posnr
where vlpma~matnr in s_matnr
and lips~lgort in s_lgort
and EXISTS ( SELECT *
FROM VBUP
WHERE vbeln eq vlpma~vbeln
and posnr eq vlpma~posnr
and wbsta IN (' ', 'A', 'B')
and kosta IN (' ', 'A', 'B') ).
Edited by: Erik Peterson on Dec 1, 2009 9:05 AM -
Sales Document from VBAK ,VBAP and VEDA
Hi ,
I need to fetch the Sales Document from VBAK and VBAP and VEDA with the contract sign date for sales document line item .
Contract sign date is in selection screen as select options.
Please let me know how to fetch the sales Document per line item from these 3 tables considering that A sales document could have many line items and each can have a different sign date.
Thanks
SachinHi,
The link between all the tables VBAK, VBAP and VEDA is VBELN i.e sales document number.
However, while fetching from VBAP and VEDA you would need to consider POSNR as well.
As your ABAPer to code the logic using 'for all entries' method.
Regards,
Amit
Edited by: Amit Iyer on Jun 23, 2011 12:28 PM -
View on vbuk,vbak,vbap,vbkd
hi all ,
is there any view on vbuk,vbak,vbap,vbkd.
Regards
MartinHI
/BEV1/LAHLIENR_V
/BEV1/LAVMVA1_V
/BEV1/LAVMVA1_V
/BEV1/LAVMVL1_V
/BEV1/SR_SLS_BWV
EMVBAP
ENT6466
ENT6467
ENT6468
EVVBAKE
HV_SDOC_ITEM
J1IB
LIKPUK
MASSSDHEAD
MASSSDPOSVBKD
MASSVBAP
MASSVBAP
M_VMVAA
SD_BACKORDER
SD_BACKORDER
U_16002
U_16002
U_16003
U_16003
U_16022
U_16022
U_16024
U_16026
U_16028
U_16040
U_16053
U_16053
WB2_V_VBAK_VBAP
WB2_V_VBAK_VBAP
WB2_V_VBAK_VBAP2
WB2_V_VBAK_VBAP2 -
Can any one tell me how to make a join in between RESB & VBAP Table
Hi.
can any one tell me how to make a join in between RESB & VBAP Table. Please do the needful.u have Sales order number and sales order item number in RESB table..
KDAUF Sales Order Number
KDPOS Item Number in Sales Order
Maybe you are looking for
-
In firefox 3.6.13 32 bit on Windows 7 64 bit with WOW subsystem, under Tools > Addons > extensions I see four Java console entries listed. They are: Java Console 6.0.20, 6.0.21, 6.0.22 & 6.0.23. 6.0.23 is active. The other 3 are disabled with the Uni
-
Hi, Are there any standard IDOC types for the transactions 1. IW41 (Create PM Order Confirmation) - Inbound 2. Service order (IW31) - Outbound Thanks Sudheer
-
Microsoft Office 2008 not opening after installation...
Hi there, Let me run through the steps leading to this error. A couple of months ago I downloaded a trial of Microsoft Office 2008. It eventually expired and I left it on my computer. A few days ago I bought a license from Microsoft for Office 2008 i
-
I keep my ipod photo in the dock all day charging and play it every day in the dock but when i take it to go out it only plays for like 5 hours
-
Separating data combined in a string with a ";" delimiter
Post Author: debbethune CA Forum: General I have a couple fields from my file that contain data separated by a semicolon (AddOn and AddOnChg). Field is formatted as a string. How can I parse out the one component that has a value in order to be abl