Hello Experts,
Can anyone tell me "how to flush out contents of Z-table" ?
The scenario is
CASE 1)Below is my select query & based on select query,Im inserting records in the Z-database.
SELECT h~ebeln i~ebelp h~bukrs h~bsart h~statu h~aedat h~lifnr h~ekorg h~ekgrp
h~waers h~bedat h~kdatb h~kdate h~reswk h~inco1 h~inco2 h~knumv h~frgke h~loekz
h~wkurs i~matnr i~menge i~werks i~lgort i~matkl i~meins i~bprme i~konnr i~netpr
i~peinh i~pstyp i~knttp i~fistl i~mwskz i~bwtar i~txjcd j~land1 j~name1 k~zservno
t~regio "p~textid p~kbetr p~textvalue l~witht
INTO CORRESPONDING FIELDS OF TABLE itab_ekko_ekpo
FROM ( ( ( ( ekko AS h INNER JOIN ekpo AS i
ON h~ebeln = i~ebeln )
INNER JOIN lfa1 AS j ON h~lifnr = j~lifnr )
INNER JOIN j_1imovend AS k ON h~lifnr = k~lifnr )
INNER JOIN t001w AS t ON i~werks = t~werks )
** INNER JOIN zpodigvalue AS p ON h~ebeln = p~ebeln )
* INNER JOIN lfbw AS l ON h~lifnr = l~lifnr )
WHERE h~ebeln IN s_ebeln
AND h~frgke NOT IN ('S', ' ')
AND h~loekz NE 'X'
AND h~bukrs IN ( SELECT oldvalue1 FROM zdm_ruleitem WHERE rulename = 'SCOPE_COMPANY_CODE'
AND oldvalue1 IN s_bukrs[]
AND oldvalue2 = sy-sysid
AND newvalue2 = tgt_sid )
AND h~ekorg IN s_ekorg
AND h~ekgrp IN s_ekgrp
AND h~ebeln IN s_ebeln
AND h~bsart IN s_bsart
AND h~bsart NOT IN ('YNB', 'CG', 'MC', 'LOI')
AND h~bstyp EQ 'F'
AND h~aedat IN s_aedat
AND h~memorytype NE 'H'
AND i~loekz EQ ' X' (here loeks = X)
AND i~elikz NE 'X'
AND i~knttp IN s_knttp
AND i~pstyp NE '8'.
itab_zdm_po_idt_item-ebeln = itab_ekko_ekpo-ebeln. "Purchasing Document Number
itab_zdm_po_idt_item-ebelp = itab_ekko_ekpo-ebelp. "Item Number of Purchasing Document
itab_zdm_po_idt_item-mwskz = itab_ekko_ekpo-txjcd. "Tax Jurisdiction
itab_zdm_po_idt_item-zrp_app = ''. "Road permit applicable
itab_zdm_po_idt_item-zsertax_ppr = '03'. "Place of Provision Rules for Service Tax
itab_zdm_po_idt_item-regio = itab_ekko_ekpo-regio. "Region (State, Province, County)
itab_zdm_po_idt_item-zlicense = itab_ekko_ekpo-zlicense."Licence No. for Excise exemptions
itab_zdm_po_idt_item-werks = itab_ekko_ekpo-werks. "Plant
*
"To check the value of Excise Duty Exempt(
IF itab_ekko_ekpo-zedexempt = 'X'.
itab_zdm_po_idt_item-zed_epcg = ''. "EPCG Invalidation
ELSE.
itab_zdm_po_idt_item-zed_epcg = 'N'. "EPCG Invalidation
ENDIF."IF itab_ekko_ekpo-zedexempt = 'X'.
*
"To check the value of Purchase Order Digitization Text ID & Rate (condition amount or percentage)
IF itab_ekko_ekpo-textid = '05' AND itab_ekko_ekpo-kbetr <> '0'.
itab_zdm_po_idt_item-zed_in = 'Y'. "Inclusive of excise duty
ENDIF."IF itab_ekko_ekpo-textid = '05' AND itab_ekko_ekpo-kbetr <> '0'.
*
"To check the value of Purchase Order Digitization Text ID & Purchase Order Digitization Text Value
IF itab_ekko_ekpo-textid = '17' AND itab_ekko_ekpo-textvalue = 'EPCG'.
itab_zdm_po_idt_item-zlictype = 'EPCG'. "Licence type
ENDIF."IF itab_ekko_ekpo-textid = '17' AND itab_ekko_ekpo-textvalue = 'EPCG'.
*
"To check the value of Purchase Order Digitization Text ID & Purchase Order Digitization Text Value
IF itab_ekko_ekpo-textid = '19' AND itab_ekko_ekpo-textvalue = '14'.
itab_zdm_po_idt_item-y_fim = 'Y'. "Free Issue of Material Issued indicator
ENDIF."IF itab_ekko_ekpo-textid = '19' AND itab_ekko_ekpo-textvalue = '14'.
*
APPEND itab_zdm_po_idt_item.
"Inserting values into database table : 'ZDM_PO_IDT_ITEM'
INSERT into zdm_po_idt_item values itab_zdm_po_idt_item.
Here,100 records has been updated into Z-database table(For example)
CASE 2) When i change the value of LOEKZ in the select query and again run the same program,It should delete all the entries of the table & update the table with new entries.
For example as follows:
SELECT h~ebeln i~ebelp h~bukrs h~bsart h~statu h~aedat h~lifnr h~ekorg h~ekgrp
h~waers h~bedat h~kdatb h~kdate h~reswk h~inco1 h~inco2 h~knumv h~frgke h~loekz
h~wkurs i~matnr i~menge i~werks i~lgort i~matkl i~meins i~bprme i~konnr i~netpr
i~peinh i~pstyp i~knttp i~fistl i~mwskz i~bwtar i~txjcd j~land1 j~name1 k~zservno
t~regio "p~textid p~kbetr p~textvalue l~witht
INTO CORRESPONDING FIELDS OF TABLE itab_ekko_ekpo
FROM ( ( ( ( ekko AS h INNER JOIN ekpo AS i
ON h~ebeln = i~ebeln )
INNER JOIN lfa1 AS j ON h~lifnr = j~lifnr )
INNER JOIN j_1imovend AS k ON h~lifnr = k~lifnr )
INNER JOIN t001w AS t ON i~werks = t~werks )
** INNER JOIN zpodigvalue AS p ON h~ebeln = p~ebeln )
* INNER JOIN lfbw AS l ON h~lifnr = l~lifnr )
WHERE h~ebeln IN s_ebeln
AND h~frgke NOT IN ('S', ' ')
AND h~loekz NE 'X'
AND h~bukrs IN ( SELECT oldvalue1 FROM zdm_ruleitem WHERE rulename = 'SCOPE_COMPANY_CODE'
AND oldvalue1 IN s_bukrs[]
AND oldvalue2 = sy-sysid
AND newvalue2 = tgt_sid )
AND h~ekorg IN s_ekorg
AND h~ekgrp IN s_ekgrp
AND h~ebeln IN s_ebeln
AND h~bsart IN s_bsart
AND h~bsart NOT IN ('YNB', 'CG', 'MC', 'LOI')
AND h~bstyp EQ 'F'
AND h~aedat IN s_aedat
AND h~memorytype NE 'H'
AND i~loekz EQ ' ' (Now loekz = ' ' ).
AND i~elikz NE 'X'
AND i~knttp IN s_knttp
AND i~pstyp NE '8'.
What sould be my query here to remove the existing records in the z-database & update the no. of records accordingly.
Thanks
SK