15 Jan 2009

ABAP program to find prev request in cube and delete

There will be cases when we cannot use the SAP built-in settings to delete previous request..The logic to determine previous request may be so customised, a requirement.
In such cases you can write a ABAP program which calculates previous request basing our own defined logic.
Following are the tables used :
RSICCONT ---(list of all requests in any particular cube)
RSSELDONE ----- ( has got Reqnumb, source , target , selection infoobject , selections ..etc)
Following is one example code. Logic is to select request based on selection conditions used in the infopackage:
REPORT ZGET_LAST_REQ_SHORT_RUN.
PARAMETERS : TAR_CUBE(9) TYPE C,
SOUR_ODS(9) TYPE C.
DATA : IT_REQ LIKE TABLE OF RSICCONT.
data : it_REQ_WA type RSICCONT.
DATA : IT_CALMONTH_LOW TYPE /BI0/OICALMONTH.
DATA : IT_CALMONTH_HIGH TYPE /BI0/OICALMONTH.
data : diff type N.
DATA : IT_REQ_CUBE LIKE TABLE OF RSSELDONE.
data : it_REQ_CUBE_WA type RSSELDONE.
data : sour_tar(22) type C.
TABLES : ZBW_PARAM.
CLEAR It_REQ.
CLEAR it_REQ_WA.
CLEAR it_REQ_CUBE.
CLEAR DIFF.
concatenate SOUR_ODS '_TO_' TAR_CUBE INTO SOUR_TAR.
SELECT * FROM RSICCONT INTO TABLE IT_REQ WHERE ICUBE = TAR_CUBE.
LOOP AT IT_REQ INTO IT_REQ_WA.
SELECT * FROM RSSELDONE INTO TABLE IT_REQ_CUBE WHERE RNR = IT_REQ_WA-RNR AND SOURCE = SOUR_ODS AND FIELDNAME = 'CALMONTH'.
ENDLOOP.
LOOP AT IT_req_cube into it_req_cube_wa.
IT_CALMONTH_LOW = IT_REQ_CUBE_wa-LOW.
IT_CALMONTH_HIGH = IT_REQ_CUBE_wa-HIGH.
diff = IT_CALMONTH_HIGH - IT_CALMONTH_LOW.
if diff <= 3.
ZBW_PARAM-ZKEY1 = 'INV_SHORT_REQ'.
ZBW_PARAM-ZKEY2 = SOUR_TAR.
ZBW_PARAM-ZDATA = IT_REQ_CUBE_WA-RNR.
MODIFY ZBW_PARAM.
ENDIF.
endloop.

Once after reqnumb is found out, you can pass
cubename, reqnumb as inputs to FM : RSSM_DELETE_REQUEST and get the job done.

2 comments:

Negi said...

Thanks for great information you write it very clean. I am very lucky to get this tips from you


Pick and pack warehousing

Canadian Frieght Quote said...

Canadian Freight Quote provides the best solutions for the transportation and shipping services to anywhere in Canada and North America. It provides the best freight shipping services for industrial and manufacturing goods at best price in Canada. Canadian Freight Quote Provides many transport and shipping services Visit@ https://www.canadianfreightquote.com/