Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Abap code in bw please help me

Former Member
0 Kudos

Hi all,

My requirement is

1. Users will be using the file upload Tcode in BW ( This TCode access will be authorized to specifi users)

2. ABAP Program need to place the file in the specified folder. Use the Z_FLATFILE_UPLOAD as a start. Copy to New program and work witht he New program

3. The ABAP program should be able to sent Trigger event after placingt he file to start the Process Chain, in which The flat file should be able to load to the ODS.

4. On Successful completion of the Process chain, the specific user group should be able to recive the email Message that the uploaded file has been loaded and avaible for reporting.

The ABAP program should be able to handle the follwing:

1. If the File Format is not correct the user should get an error message that the file is not in the expected format.

2. Once the File upload complete, user should see the message that the file uploaded correctly.

3. on Successful completion of the FileUpload, The program should trigger event.

and the program Z_FLATFILE_UPLOAD is given below

REPORT Z_FLATFILE_UPLOAD message-id zx .

PARAMETERS: FILE_NM LIKE RLGRAP-FILENAME obligatory.

PARAMETERS: P2 LIKE RLGRAP-FILENAME

DEFAULT '/Userdata/IFIN/0557'.

DATA: INRECORD_COUNT TYPE i,

OUTRECORD_COUNT TYPE i.

DATA : MASK(20) TYPE C VALUE ',. ,..'.

DATA: BEGIN OF ITAB OCCURS 0,

RECORD(3000),

END OF ITAB.

  • AT selection screen help and F4 statements

AT SELECTION-SCREEN ON VALUE-REQUEST FOR FILE_NM.

CALL FUNCTION 'WS_FILENAME_GET'

EXPORTING

DEF_FILENAME = ' '

DEF_PATH = FILE_NM

MASK = MASK

MODE = 'O'

TITLE = 'File Select'

IMPORTING

FILENAME = FILE_NM

EXCEPTIONS

INV_WINSYS = 04

NO_BATCH = 08

SELECTION_CANCEL = 12

SELECTION_ERROR = 16.

IF FILE_NM = ' ' AND SY-SUBRC = 12.

SET CURSOR FIELD 'FILE_NM'.

MESSAGE I000(ZX) with 'File Selection cancelled.'

'Please select a valid file to proceed'.

ELSEIF SY-SUBRC NE 0.

MESSAGE E000(ZX) WITH FILE_NM.

EXIT.

ENDIF.

START-OF-SELECTION.

CALL FUNCTION 'UPLOAD'

EXPORTING

FILENAME = FILE_NM

TABLES

DATA_TAB = ITAB.

if sy-subrc <> 0.

message i000(ZX) with 'Upload Failed'.

LEAVE LIST-PROCESSING.

endif.

*editor-call for input_rec.

OPEN DATASET P2 FOR output IN text mode encoding default.

IF SY-SUBRC <> 0.

message i000(ZX) with 'COULD NOT OPEN THE FILE'.

LEAVE LIST-PROCESSING.

ENDIF.

INRECORD_COUNT = 0.

OUTRECORD_COUNT = 0.

LOOP AT ITAB. .

INRECORD_COUNT = INRECORD_COUNT + 1.

TRANSFER ITAB-RECORD TO P2.

OUTRECORD_COUNT = OUTRECORD_COUNT + 1.

ENDLOOP. "itab

END-OF-SELECTION.

CLOSE DATASET P2.

IF SY-SUBRC <> 0.

message e000(ZX) with 'COULD NOT OPEN THE FILE'.

ENDIF.

WRITE: / '# of records read ', INRECORD_COUNT,

/ '# of records transfered', OUTRECORD_COUNT.

WRITE:/ 'upload filename', FILE_NM.

WRITE:/ ' aix filename', P2.

after this code i need to trigger my event can any onle tell me the steps after this program and the code also plese

thanks in advance

Sri

points will be assigned

2 REPLIES 2

Former Member
0 Kudos

Patnaik,

I think u know upto 2nd step of ABAP part of ur solution.

I think following helps you.

Triggering an event notifies the background processing system that a named condition has been reached.

The background processing system reacts by starting any jobs that were waiting for the event.

http://help.sap.com/saphelp_nw04s/helpdata/en/fa/096e37543b11d1898e0000e8322d00/frameset.htm

Use function module BP_EVENT_RAISE to trigger an event from an ABAP program.

Example

  • Report processing before triggering event...

  • Trigger event to start background jobs waiting for the event.

DATA: EVENTID LIKE TBTCJOB-EVENTID.

DATA: EVENTPARM LIKE TBTCJOB-EVENTPARM.

EVENTID = 'SP_TEST_EVENT'. " Event name must be defined

" with transaction SM62.

EVENTPARM = 'EVENT1'. " Optional: a job can be

" scheduled to wait for an

" EVENTID or combination of

" EVENTID and EVENTPARM.

CALL FUNCTION 'BP_EVENT_RAISE' " Event is triggered. Jobs

EXPORTING " waiting for event will be

EVENTID = EVENTID " started.

EVENTPARM = EVENTPARM

TARGET_INSTANCE = ‘ ‘ " Instance at which an event

" should be processed. Can

" generally be omitted.

EXCEPTIONS OTHERS = 1. " Exceptions include event not

" defined, no EVENTID

" exported, etc

<b>

Reward points if useful</b>

PRaneeth

Former Member
0 Kudos

thank u guyz