‎2007 Dec 17 5:37 AM
hi
is it possible to do validations in interfaces if so how
if possible with example
‎2007 Dec 17 6:00 AM
Hi sachin,
In Interfaces (OOPS concept) you cannot validate Data. Generally Interfaces are used for Validation purpose. like if you want to validate some data in many classes, in that case you just create an interface and declare method for that validation and implement that interface in all classes where you want that validation.
Regards,
Sachin Bhatnagar.
‎2007 Dec 17 6:00 AM
Hi sachin,
In Interfaces (OOPS concept) you cannot validate Data. Generally Interfaces are used for Validation purpose. like if you want to validate some data in many classes, in that case you just create an interface and declare method for that validation and implement that interface in all classes where you want that validation.
Regards,
Sachin Bhatnagar.
‎2007 Dec 17 6:04 AM
hi Sachin.,
we can do validations in interfaces.
before seneding the data into SAP/ Files we need to do all validations for the data depends up on the requirement.
the validations totally depends on the req. only.
here im attaching the piece of code in which validations has been done for interface.
go through it for better understanding.
&----
*& Form get_data
&----
*
&----
FORM get_data .
CONSTANTS: lc_repid TYPE sy-repid VALUE sy-repid.
*Select the last run date and time of the program.
SELECT mandt
lrprogram
lrdate
lrtime
INTO ls_runtimdat
FROM zmt_last_run
WHERE lrprogram = lc_repid.
ENDSELECT.
IF ls_runtimdat IS NOT INITIAL.
SELECT lips~vgbel
likp~berot
likp~bolnr
likp~xabln
likp~btgew
likp~wadat_ist
likp~wauhr
likp~traid
likp~vbeln
ekko~ihrez
INTO TABLE gt_tab
FROM likp
JOIN lips
ON likpvbeln = lipsvbeln
JOIN ekko
ON ekkoebeln = lipsvgbel
WHERE wadat_ist GE ls_runtimdat-lrdate
AND ( lfart LIKE gc_dtyp_end
OR lfart EQ gc_dtyp_stat ).
DELETE gt_tab WHERE wadat_ist EQ ls_runtimdat-lrdate
AND wauhr LT ls_runtimdat-lrtime.
ELSE.
SELECT lips~vgbel
likp~berot
likp~bolnr
likp~xabln
likp~btgew
likp~wadat_ist
likp~wauhr
likp~traid
likp~vbeln
ekko~ihrez
INTO TABLE gt_tab
FROM likp
JOIN lips
ON likpvbeln = lipsvbeln
JOIN ekko
ON ekkoebeln = lipsvgbel
WHERE wadat_ist LE sy-datum
AND ( lfart LIKE gc_dtyp_end
OR lfart EQ gc_dtyp_stat ).
DELETE gt_tab WHERE wadat_ist EQ sy-datum
AND wauhr GT sy-uzeit.
ENDIF.
ENDFORM. " get_data
&----
*& Form get_convert_ship_data
&----
This subroutine converts(BTGEW) which is Quan field into Char field.
----
FORM get_convert_ship_data .
LOOP AT gt_tab INTO ls_tab.
MOVE: ls_tab-vgbel TO ls_output-vgbel,
ls_tab-berot TO ls_output-berot,
ls_tab-bolnr TO ls_output-bolnr,
ls_tab-xabln TO ls_output-xabln,
ls_tab-btgew TO ls_output-btgew,
ls_tab-wadat_ist TO ls_output-wadat_ist,
ls_tab-wauhr TO ls_output-wauhr,
ls_tab-traid TO ls_output-traid.
APPEND ls_output TO gt_output.
ENDLOOP.
ENDFORM. " get_convert_ship_data
&----
*& Form f_createidoc
&----
This routine calls the function module for creation of idocs
Z_GENERIC_IDOC_CREATE passing relevant parameters.
*
----
FORM f_createidoc .
CALL FUNCTION 'Z_GENERICIDOC_CREATE'
EXPORTING
iv_mestyp = 'ZSHPTMS'
TABLES
it_data = gt_output.
ENDFORM. " f_createidoc
&----
*& Form last_run_date_time
&----
This Routine is used to update the last run Date & Time
in the ZMT_LAST_RUN table for the Program.
----
FORM last_run_date_time .
Updating the ZMT_LAST_RUN table with current date & time
ls_runtimdat-mandt = sy-mandt.
ls_runtimdat-lrprogram = sy-repid.
ls_runtimdat-lrdate = sy-datum.
ls_runtimdat-lrtime = sy-uzeit.
Update the Ztable with current date and time
MODIFY zmt_last_run FROM ls_runtimdat.
COMMIT WORK. " Committing update to ZMT_LAST_RUN
ENDFORM. " last_run_date_time
&----
*& Form get_unrelevant_data
&----
This is used to create Error Log for the records when the shipment
number is different in EKKO(IHREZ) & LIKP(BEROT).
Also create Error log when the Vendor is different in VBPA(LIFNR)
& EKPA(LIFN2).
----
FORM get_unrelevant_data.
DATA: lv_lifn2 TYPE ekpa-lifn2,
lv_lifnr TYPE vbpa-lifnr,
lv_descript(20) TYPE c.
CONSTANTS: lc_posnr(6) TYPE c VALUE '000000',
lc_parvw(2) TYPE c VALUE 'SP'.
SELECT ebeln lifn2
FROM ekpa
INTO TABLE gt_ekpa
FOR ALL ENTRIES IN gt_tab
WHERE ebeln = gt_tab-vgbel
AND parvw = lc_parvw.
SELECT vbpa~vbeln
vbpa~lifnr
lfa1~scacd
INTO TABLE gt_vbpa
FROM vbpa
JOIN lfa1
ON vbpalifnr = lfa1lifnr
FOR ALL entries IN gt_tab
WHERE vbeln = gt_tab-vbeln
AND posnr = lc_posnr
AND parvw = lc_parvw.
LOOP AT gt_tab INTO ls_tab.
READ TABLE gt_ekpa INTO ls_ekpa
WITH KEY ebeln = ls_tab-vgbel.
IF sy-subrc EQ 0.
lv_lifn2 = ls_ekpa-lifn2.
ELSE.
CLEAR: lv_lifn2.
ENDIF.
CLEAR: ls_vbpa-scacd.
READ TABLE gt_vbpa INTO ls_vbpa
WITH KEY vbeln = ls_tab-vbeln.
IF sy-subrc EQ 0.
lv_lifnr = ls_vbpa-lifnr.
ELSE.
CLEAR: lv_lifnr.
ENDIF.
CLEAR: ls_output.
READ TABLE gt_output INTO ls_output
WITH KEY vgbel = ls_tab-vgbel.
IF sy-subrc EQ 0.
ls_output-scacd = ls_vbpa-scacd.
MODIFY gt_output FROM ls_output
INDEX sy-tabix TRANSPORTING scacd.
IF ( lv_lifn2 NE lv_lifnr ) OR
( ls_tab-ihrez NE ls_tab-berot ).
MOVE ls_output TO ls_elog_output.
APPEND ls_elog_output TO gt_elog_output.
ENDIF.
IF lv_lifn2 NE lv_lifnr.
lv_descript = text-012.
ELSEIF ls_tab-ihrez NE ls_tab-berot.
lv_descript = text-013.
ELSEIF ( lv_lifn2 NE lv_lifnr ) AND
( ls_tab-ihrez NE ls_tab-berot ).
lv_descript = text-014.
ENDIF.
MOVE lv_descript TO ls_elog_output-descript.
MODIFY gt_elog_output FROM ls_elog_output
INDEX sy-tabix TRANSPORTING descript.
ENDIF.
ENDLOOP.
ENDFORM. "get_unrelevant_data
Reward points if useful
Chandra