Posted: Mon Nov 16, 2020 7:50 pm Post subject: Выборка данных из таблиц
Коллеги, подскажите пожалуйста, как в данный код добавить выборку с условиями, куда внедрить код с условиями, что если таблица с полем пустая, то необходимо все равно идти дальше с выборкой, если есть записи, то выводить, у меня сейчас получается, что отчет только по данному признаку смотрит остальные вообще не выбираются.
Я добавил в отчет новые поля для выборки
Таблица TPRIT поля которые мне нужны были BEZEI, LPRIO
Code:
* Selection start from Inquiry
* Выборка начинается с Запроса
*----------------------------------------------------------------------*
Code:
FORM select_from_inquiry.
DATA:
ls_out LIKE LINE OF gt_out.
FIELD-SYMBOLS:
<ls_out> LIKE LINE OF gt_out.
* Select inquiry data:
SELECT t1~vbeln AS inq_vbeln
t1~posnr AS inq_posnr
t2~vkorg AS inq_vkorg
t2~vtweg AS inq_vtweg
t2~spart AS inq_spart
t2~vkgrp AS inq_vkgrp
t2~vkbur AS inq_vkbur
t2~kunnr AS inq_kunnr
t3~name1 AS inq_name1
t1~matnr AS inq_matnr
t1~arktx AS inq_arktx
t1~kwmeng AS inq_kwmeng
t1~vrkme AS inq_vrkme
t1~netpr AS inq_netpr
t1~waerk AS inq_waerk
t4~kursk AS inq_kursk
t2~audat AS inq_audat
t2~zuonr AS inq_zuonr
t2~bstnk AS inq_bstnk
t2~objnr AS inq_objnr_nod
t1~abgru AS inq_abgru
t4~zterm AS inq_zterm
t1~LPRIO AS inq_LPRIO " Приоритет поставки
t0~BEZEI AS inq_BEZEI " Имя приоритета поставки
FROM vbap AS t1
JOIN vbak AS t2
ON t2~vbeln = t1~vbeln
JOIN kna1 AS t3
ON t3~kunnr = t2~kunnr
JOIN vbkd AS t4
ON t4~vbeln = t1~vbeln
INNER JOIN TPRIT AS t0 " Имя приоритета поставки
ON t0~BEZEI = t0~BEZEI " Имя приоритета поставки
AND t0~LPRIO = t1~LPRIO " Приоритет поставки
INTO CORRESPONDING FIELDS OF TABLE gt_out
WHERE t2~auart IN gt_auart
AND t1~vbeln IN s_inq_no
AND t1~matnr IN s_inq_mt
AND t2~kunnr IN s_inq_kn
AND t2~bstnk IN s_inq_bs
AND t2~audat IN s_inq_au
AND t2~vkorg IN s_vkorg
AND t2~vtweg IN s_vtweg
AND t2~spart IN s_spart
AND t2~vkgrp IN s_vkgrp
AND t2~vkbur IN s_vkbur
" AND t1~LPRIO IN s_inq_lp " Приоритет поставки
AND t0~BEZEI IN s_inq_be " Имя приоритета поставки
AND t0~spras = sy-langu. " Имя приоритета поставки
CHECK NOT gt_out IS INITIAL.
TYPES:
BEGIN OF lty_sales,
vbelv TYPE vbfa-vbelv,
posnv TYPE vbfa-posnv,
so_vbeln TYPE vbfa-vbeln,
so_posnr TYPE vbfa-posnn,
so_kunnr TYPE vbak-kunnr,
so_name1 TYPE kna1-name1,
so_matnr TYPE vbap-matnr,
so_arktx TYPE vbap-arktx,
so_kwmeng TYPE vbap-kwmeng,
so_vrkme TYPE vbap-vrkme,
so_netpr TYPE vbap-netpr,
so_waerk TYPE vbap-waerk,
so_kursk TYPE vbkd-kursk,
so_audat TYPE vbak-audat,
so_bstnk TYPE vbak-bstnk,
so_prod_grp TYPE vbak-zzprod_grp_code,
so_bstkd TYPE bstkd,
so_LPRIO TYPE vbap-LPRIO, " Приоритет поставки
so_BEZEI TYPE TPRIT-BEZEI, " Имя приоритета поставки
END OF lty_sales.
DATA:
lt_sales TYPE SORTED TABLE OF lty_sales
WITH NON-UNIQUE KEY vbelv posnv.
FIELD-SYMBOLS:
<ls_sales> LIKE LINE OF lt_sales.
* Select Sales order data:
SELECT t1~vbelv
t1~posnv
t1~vbeln AS so_vbeln
t1~posnn AS so_posnr
t2~kunnr AS so_kunnr
t4~name1 AS so_name1
t3~matnr AS so_matnr
t3~arktx AS so_arktx
t3~kwmeng AS so_kwmeng
t3~vrkme AS so_vrkme
t3~netpr AS so_netpr
t3~waerk AS so_waerk
t5~kursk AS so_kursk
t2~audat AS so_audat
t2~bstnk AS so_bstnk
t2~zzprod_grp_code AS so_prod_grp
t5~bstkd AS so_bstkd
t3~LPRIO AS so_LPRIO " Приоритет поставки
t0~BEZEI AS so_BEZEI " Имя приоритета поставки
FROM vbfa AS t1
JOIN vbak AS t2
ON t2~vbeln = t1~vbeln
JOIN vbap AS t3
ON t3~vbeln = t1~vbeln
AND t3~posnr = t1~posnn
JOIN kna1 AS t4
ON t4~kunnr = t2~kunnr
JOIN vbkd AS t5
ON t5~vbeln = t2~vbeln
JOIN TPRIT AS t0 " Имя приоритета поставки
ON t0~BEZEI = t0~BEZEI " Имя приоритета поставки
INTO TABLE lt_sales
FOR ALL ENTRIES IN gt_out
WHERE t1~vbelv = gt_out-inq_vbeln
AND t1~posnv = gt_out-inq_posnr
AND t3~LPRIO = gt_out-inq_LPRIO " Приоритет поставки
AND t1~vbtyp_n EQ gc_c
AND t1~rfmng > 0.
TYPES:
BEGIN OF lty_delivery,
vbelv TYPE vbfa-vbelv,
posnv TYPE vbfa-posnv,
dlv_vbeln TYPE vbfa-vbeln,
dlv_posnr TYPE vbfa-posnn,
dlv_lgort TYPE lips-lgort,
dlv_matnr TYPE lips-matnr,
dlv_arktx TYPE lips-arktx,
dlv_lfimg TYPE lips-lfimg,
dlv_vrkme TYPE lips-vrkme,
dlv_kodat TYPE likp-kodat,
dlv_wadat_ist TYPE likp-wadat_ist,
END OF lty_delivery.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.