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: 

Exporting BDC program to Word or Notepad file

Former Member
0 Kudos

hellow sirs,

is ther any way out for Automating the Export of BDC program

( Source Code) into Word file or note pad file..

i.e.. whenever i run my BDC it performs its function as well as it copy its Source Code into Word File..

thanking you

Rahul

1 ACCEPTED SOLUTION

venkat_o
Active Contributor
0 Kudos

HI Rahul . Check this sample program to download source code of the program . Club your BDC program and this to get ur req done.

*&---------------------------------------------------------------------*
*& Report  YDWNLD_REP
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  ydwnld_rep.

TABLES: trdir,trdirt,devaccess,tadir.

DATA: BEGIN OF itab OCCURS 0,
      text(300),
      END OF itab.
DATA program LIKE rlgrap-filename .

DATA: BEGIN OF int_reposrc OCCURS 0,
      progname LIKE trdir-name,
      END OF int_reposrc.

*------------------------------------------------------------------*
SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME.
*PARAMETER CNAM LIKE TRDIR-CNAM.
SELECT-OPTIONS: author FOR trdir-cnam.
SELECT-OPTIONS: pogram FOR trdir-name OBLIGATORY.
PARAMETERS: filename LIKE rlgrap-filename OBLIGATORY DEFAULT 'C:\'.
SELECTION-SCREEN END OF BLOCK b1.
*------------------------------------------------------------------*

SELECT * FROM devaccess.
  CLEAR author.
  author-sign = 'I'.
  author-option = 'EQ'.
  author-low =  devaccess-uname.
  APPEND author.
ENDSELECT.

SELECT name  FROM trdir INTO TABLE int_reposrc
                      WHERE name IN pogram
                      AND   cnam  IN author.

LOOP AT int_reposrc.
  CLEAR: itab,program.
  REFRESH itab.
  READ REPORT int_reposrc-progname INTO itab.
  IF sy-subrc = 0.
    CLEAR trdirt.
    SELECT SINGLE * FROM trdirt WHERE name  =  int_reposrc-progname
                                AND   sprsl = 'E'.

    CLEAR tadir.

    SELECT SINGLE * FROM tadir WHERE obj_name = int_reposrc-progname.
    CONCATENATE filename tadir-devclass '\' int_reposrc-progname '-'
                 trdirt-text '.TXT'  INTO program.
    IF NOT itab[] IS INITIAL.
      CALL FUNCTION 'WS_DOWNLOAD'
        EXPORTING
          filename                = program
          filetype                = 'DAT'
        TABLES
          data_tab                = itab
        EXCEPTIONS
          file_open_error         = 1
          file_write_error        = 2
          invalid_filesize        = 3
          invalid_type            = 4
          no_batch                = 5
          unknown_error           = 6
          invalid_table_width     = 7
          gui_refuse_filetransfer = 8
          customer_error          = 9
          no_authority            = 10
          OTHERS                  = 11.

    ENDIF.
  ENDIF.
ENDLOOP.
I hope that it helps u . Regards, Venkat.O

6 REPLIES 6

venkat_o
Active Contributor
0 Kudos

HI Rahul . Check this sample program to download source code of the program . Club your BDC program and this to get ur req done.

*&---------------------------------------------------------------------*
*& Report  YDWNLD_REP
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  ydwnld_rep.

TABLES: trdir,trdirt,devaccess,tadir.

DATA: BEGIN OF itab OCCURS 0,
      text(300),
      END OF itab.
DATA program LIKE rlgrap-filename .

DATA: BEGIN OF int_reposrc OCCURS 0,
      progname LIKE trdir-name,
      END OF int_reposrc.

*------------------------------------------------------------------*
SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME.
*PARAMETER CNAM LIKE TRDIR-CNAM.
SELECT-OPTIONS: author FOR trdir-cnam.
SELECT-OPTIONS: pogram FOR trdir-name OBLIGATORY.
PARAMETERS: filename LIKE rlgrap-filename OBLIGATORY DEFAULT 'C:\'.
SELECTION-SCREEN END OF BLOCK b1.
*------------------------------------------------------------------*

SELECT * FROM devaccess.
  CLEAR author.
  author-sign = 'I'.
  author-option = 'EQ'.
  author-low =  devaccess-uname.
  APPEND author.
ENDSELECT.

SELECT name  FROM trdir INTO TABLE int_reposrc
                      WHERE name IN pogram
                      AND   cnam  IN author.

LOOP AT int_reposrc.
  CLEAR: itab,program.
  REFRESH itab.
  READ REPORT int_reposrc-progname INTO itab.
  IF sy-subrc = 0.
    CLEAR trdirt.
    SELECT SINGLE * FROM trdirt WHERE name  =  int_reposrc-progname
                                AND   sprsl = 'E'.

    CLEAR tadir.

    SELECT SINGLE * FROM tadir WHERE obj_name = int_reposrc-progname.
    CONCATENATE filename tadir-devclass '\' int_reposrc-progname '-'
                 trdirt-text '.TXT'  INTO program.
    IF NOT itab[] IS INITIAL.
      CALL FUNCTION 'WS_DOWNLOAD'
        EXPORTING
          filename                = program
          filetype                = 'DAT'
        TABLES
          data_tab                = itab
        EXCEPTIONS
          file_open_error         = 1
          file_write_error        = 2
          invalid_filesize        = 3
          invalid_type            = 4
          no_batch                = 5
          unknown_error           = 6
          invalid_table_width     = 7
          gui_refuse_filetransfer = 8
          customer_error          = 9
          no_authority            = 10
          OTHERS                  = 11.

    ENDIF.
  ENDIF.
ENDLOOP.
I hope that it helps u . Regards, Venkat.O

Former Member
0 Kudos

thanks a heaps

venkat.

i m goin to use wil let you know as soon as i get things done.

cheers

rahul

Former Member
0 Kudos

thankin you so much.. Venkat..

this works really well

here i'm assigning u points as my Gesture for ur effort..!

and yes can u emailme . step by step method for Creating Reports using LDB method and ALV

thanks and Regards

Rahul

venkat_o
Active Contributor
0 Kudos

Rahul, You are always welcome. Regards, Venkat.O

Former Member
0 Kudos

Hi Rahul,

U can write a program to meet your requirement. Just record the BDC of se38 as followed.

goto se38

mention the program name.

display.

export from se38. There is an option to export the file from SAP.

This will export your source code to a word file.

Venkat.

0 Kudos

hellow venkat

thanks for ur response..

i know there is a ooption

but i want to perform this thing thru program. i dont want to do manuallly

i want to automate..

thanks. and Regards

Rahul