SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

SQ01 Query download on Appl Server using enhancment SQUE0001



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> List Generation, LDB, Spool Process, SAP Query, Report Painter
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1636

PostPosted: Sat Sep 08, 2007 7:23 pm    Post subject: SQ01 Query download on Appl Server using enhancment SQUE0001 Reply with quote

Requirement:
Implement enhancment SQUE0001, user-exit EXIT_RSAQEXCE_001.

Processing:
The processing to implement the user-exit is as below:

First create a Project through transaction CMOD say ZSQFILE .
Then use enhancement assignment to include SQUE0001 SAP Query: Private data file
Further implement the user-exit EXIT_RSAQEXCE_001 in the component section .
Click on Include ZXQUEU01 to create it and then implement the given code. Please change the 'SharedFileDirectoryName' to replace with your shared directory ( Directory that you should be able to see / configure through transaction AL11 )
Activate the user- exit.
Now Run SQ01 ( Background or foreground ) and select 'Private file' ( and not File Store ) on the selction screen. Further it will download the results in a file on folder as specifird in the code as .
Please understand that a parameter can't be provided for file name, it will be downloaded as the description name of the query <.txt >. As it is, it will create a tab separated file.

ABAP Code:
Code:
*&---------------------------------------------------------------------*
*&  Include           ZXQUEU01                                         *
*&---------------------------------------------------------------------*
* Implemented by: Ram Manohar Tiwari
* Presented by  : www.rmtiwari.com
* Function      : Enhancement SQUE0001 : SAP Query - Private Data File
*                 User-Exit FM : EXIT_RSAQEXCE_001
*                 to download the SQ01 Query Results on application
*                 server as tab separated data file.
*----------------------------------------------------------------------*

class cl_abap_char_utilities definition load.

DATA : lv_file_name LIKE rlgrap-filename.
DATA : empty(1),
       fcnt  TYPE i,
       fpos  TYPE i,
       cfpos TYPE i,
       feld(1000).

DATA: BEGIN OF ldata OCCURS 100.
        INCLUDE STRUCTURE rsaqldata.
DATA: END OF ldata,
      maxpos TYPE i.


FIELD-SYMBOLS: <feld>,
               <cfeld>.
DATA: l_pos TYPE i.

data: l_length    type i,
      l_number(3) type n,
      l_pos_f     type i.

constants: bufferlength type i value 1024.
constants: lc_tab type X value '09'.

REFRESH ldata.

LOOP AT datatab.
  CLEAR ldata.
  maxpos = 0.

  fcnt = 0.
  LOOP AT listdesc WHERE lid = list_id.
    fcnt = fcnt + 1.
    IF fcnt <> 1.
      l_pos = maxpos + 1.
      IF l_pos > bufferlength.
        APPEND ldata.
        CLEAR ldata.
        maxpos = 0.
      ENDIF.

    ENDIF.
    fpos = listdesc-flpos.
    ASSIGN COMPONENT fpos OF STRUCTURE datatab TO <feld>.
    WRITE <feld> TO feld.
    SHIFT feld LEFT DELETING LEADING space.
    l_length = strlen( feld ).
    l_number = l_length.

    l_pos_f = maxpos + l_length + 1.
    if l_pos > bufferlength.
      append ldata.
      clear ldata.
      maxpos = 0.
    endif.
    IF fcnt <> 1.
      concatenate ldata CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB
                  feld  into ldata.
    else.
      concatenate ldata
                  feld  into ldata.
    ENDIF.

    maxpos = maxpos + strlen( l_number ) + 1 + l_length.


  ENDLOOP.
  APPEND ldata.
  CLEAR ldata.
ENDLOOP.

DATA : lv_list_name(15) type C,
       lv_length        type i.

lv_length = strlen( listtext ).

if lv_length < 15.
  lv_list_name = listtext.
else.
  lv_list_name = listtext(15).
endif.

CONCATENATE '\\SharedFileDirectoryName\' lv_list_name '_'
            sy-SLSET '.txt'  INTO lv_file_name.


OPEN DATASET lv_file_name FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

LOOP AT ldata.

  TRANSFER ldata TO lv_file_name.

ENDLOOP.

CLOSE DATASET lv_file_name.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> List Generation, LDB, Spool Process, SAP Query, Report Painter All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.