Skip to Content
0
Former Member
Feb 09, 2011 at 11:52 PM

BAPI Help

48 Views

Hi All,

I have this BAPI which is getting data from tstc and tstct tables. The data has 200k+ records, I need to display 50K at a time. Can someone please help me with this.

Thanks,

SNReddy

FUNCTION bptcoddata_extract.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     VALUE(FILEPATH) TYPE  RLGRAP-FILENAME OPTIONAL
*"     VALUE(STANDARD_TABLES) TYPE  FLAG DEFAULT 'X'
*"     VALUE(CONNECTOR) TYPE  CHAR5 OPTIONAL
*"     VALUE(TCODE_DATA) TYPE  FLAG DEFAULT 'X'
*"     VALUE(TCODE_SELECT) TYPE  STRING OPTIONAL
*"  TABLES
*"      TBL_BAPIRET STRUCTURE  BAPIRET2 OPTIONAL
*"      TCODES STRUCTURE  TWBTCODE OPTIONAL
*"      TCODES_DESC STRUCTURE  TSTCT OPTIONAL
*"----------------------------------------------------------------------

  DATA : t_tcodes_tstc TYPE STANDARD TABLE OF twbtcode,
         wa_bapiret TYPE bapiret2,
         t_tcodes TYPE STANDARD TABLE OF ty_tcodes,
         wa_tcodes TYPE ty_tcodes,
         lv_filename TYPE string,
         t_tcodes_script TYPE tt_tcodes_script,
         wa_tcodes_script TYPE stcodes_script,
         t_bapiret TYPE STANDARD TABLE OF bapiret2,
         wa_tstct TYPE tstct,
         t_seluserstr TYPE STANDARD TABLE OF ssel_user_str.


*If there is any pattern sent for Transaction codes then use the same for fetching Transaction codes
  IF NOT tcode_select IS INITIAL.
    PERFORM process_tcodepattern TABLES t_seluserstr
                                  USING tcode_select.
  ENDIF.

  IF tcode_data = 'X'.
* Fetch All Transaction codes from the SAP system
    IF standard_tables = 'X'.
      IF t_seluserstr[] IS INITIAL.
        select * into corresponding fields of table tcodes from tstc.
        select * into corresponding fields of table tcodes_desc from
          tstct where sprsl = 'E'.
      ELSE.
        select * into corresponding fields of table tcodes from tstc
          where tcode in t_seluserstr[].
        select * into corresponding fields of table tcodes_desc from
          tstct where sprsl = 'E' and tcode in t_seluserstr[].
      ENDIF.

    ELSE.
      IF t_seluserstr[] IS INITIAL.
        SELECT tcode FROM (lv_alrttstc) INTO TABLE t_tcodes_tstc WHERE tcode NE space AND sprsl = 'E'.
      ELSE.
        SELECT tcode FROM (lv_alrttstc) INTO TABLE t_tcodes_tstc WHERE tcode IN t_seluserstr[] AND sprsl = 'E'.
      ENDIF.

      SELECT sprsl tcode ttext FROM (lv_alrttstct)
      INTO CORRESPONDING FIELDS OF TABLE t_tcodes
      FOR ALL ENTRIES IN t_tcodes_tstc
      WHERE   sprsl = 'E' AND
              tcode = t_tcodes_tstc-tcode.

    ENDIF.

    IF sy-subrc <> 0.
      wa_bapiret-type = 'E'.
      wa_bapiret-id = 'MSG'.
      wa_bapiret-number = '000'.
      wa_bapiret-message = 'There are no Transaction Codes available in the System'."#EC NOTEXT
      APPEND wa_bapiret TO tbl_bapiret.
      CLEAR wa_bapiret.
      EXIT.
    ENDIF.


    FREE : t_tcodes_tstc.
  ENDIF.

ENDFUNCTION.