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: 

About the following dump for my code .

rishi_kulkarni123
Participant
0 Kudos
319

Hello All,

I am facing the dump for which I am not getting the proper solution. I have created the FM to convert the internal table to excel format dynamically but for a particular field when the value is negative it is giving me an error.

FUNCTION ZDYNAMIC_EXCEL_CREATION.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     REFERENCE(GT_FIELDCAT) TYPE  SLIS_T_FIELDCAT_ALV
*"     REFERENCE(DEFAULT_FILE_PATH) TYPE  STRING
*"  TABLES
*"      IT_TAB
*"----------------------------------------------------------------------
  TYPE-POOLS :SLIS.
  FIELD-SYMBOLS : <DYN_STR>  TYPE ANY,
                  <DYN_STR1> TYPE ANY,
                  <STR_COMP> TYPE ABAP_COMPDESCR,
                  <TAB>      TYPE STANDARD TABLE,
                  <WA_TAB>   TYPE ANY,
                  <FIELD>    TYPE ANY,
                  <F_ST1>    TYPE ANY.
  FIELD-SYMBOLS : <TABLE>   TYPE STANDARD TABLE,
                  <WA_AREA> TYPE ANY.
  DATA: DATATYPE TYPE REF TO CL_ABAP_DATADESCR.
  DATA : WA_FIELDCAT LIKE LINE OF GT_FIELDCAT .
  DATA : L_STRUCTURE TYPE REF TO DATA,
         STRUC_DESC  TYPE REF TO CL_ABAP_STRUCTDESCR,
         C           TYPE STRING.
  DATA : V_VALUE TYPE STRING  .
  DATA : GT_DYN_TABLE  TYPE REF TO DATA.
*  DATA: WA_FIELDCAT TYPE   SLIS_FIELDCAT_ALV.
  DATA : GT_DYN_FCAT   TYPE LVC_T_FCAT,
         GS_FIELD_LIST TYPE STRING.
  DATA : WT_DYN_FCAT         TYPE LINE OF  LVC_T_FCAT  .
  TYPES : BEGIN OF TY_STR_HDR,
            FIELD_NAME TYPE CHAR20,
          END OF TY_STR_HDR.
  DATA  GIT_HEADER_TEXT    TYPE STANDARD TABLE OF TY_STR_HDR.
  DATA:GREF_TABLE_RESULT TYPE REF TO CL_ABAP_TABLEDESCR,  " Table
       GS_COMPONENTS     TYPE STANDARD TABLE OF ABAP_COMPONENTDESCR
                          WITH KEY NAME,
       LS_COMPONENTS     LIKE LINE OF GS_COMPONENTS.
  DATA : LR_STRUCT_RESULT TYPE REF TO CL_ABAP_STRUCTDESCR,
         LR_TABLE_RESULT  TYPE REF TO  CL_ABAP_TABLEDESCR.
  FIELD-SYMBOLS: <FS_DYNAMIC_TAB> TYPE STANDARD TABLE .
  FIELD-SYMBOLS : <LFS_STRUCT> TYPE ANY,
                  <WA_TAB1>    TYPE ANY..
  DATA: LRT_TABLE  TYPE REF TO DATA,
        LRS_STRUCT TYPE REF TO DATA.


  DATA:LV_DATA_KIND TYPE ABAP_TYPEKIND.
  DATA : STR  TYPE STRING .
  DATA : STR1 TYPE STRING .
  DATA : STR2 TYPE STRING .

  """"""""""""""""""""""""""""""""""""""""""main code """"""""""""""""""""""""""""""""""""""""""""""
  CREATE DATA L_STRUCTURE LIKE LINE OF IT_TAB.
  ASSIGN L_STRUCTURE->* TO <DYN_STR>.
  STRUC_DESC ?= CL_ABAP_TYPEDESCR=>DESCRIBE_BY_DATA( <DYN_STR> ).
  ASSIGN STRUC_DESC->COMPONENTS TO <TAB> .
  """"""""""""""""""""""""""""""dynamic structure """""""""""""""""""""""""""""""""""""""""""""""""""
  LOOP AT  GT_FIELDCAT INTO WA_FIELDCAT .
    MOVE-CORRESPONDING WA_FIELDCAT TO WT_DYN_FCAT .
    APPEND WT_DYN_FCAT TO GT_DYN_FCAT .
    CLEAR : WT_DYN_FCAT , WA_FIELDCAT .
  ENDLOOP.
*  """"""""""""""""""""""""""""""""""""""""""""field catalogue """"""""""""""""""""""""""""""""""""""
*  CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
*    EXPORTING
*      I_STYLE_TABLE             = 'X'
*      IT_FIELDCATALOG           = GT_DYN_FCAT
*    IMPORTING
*      EP_TABLE                  = GT_DYN_TABLE
*    EXCEPTIONS
*      GENERATE_SUBPOOL_DIR_FULL = 1
*      OTHERS                    = 2.
*  """"""""""""""""""""""""""""""""""""""""dynamic table creation""""""""""""""""""""""""""""""""""

  """""""""""""""""""""""""""""""""'header table creation """"""""""""""""""""""""""""""""""""""""

  LOOP AT  GT_DYN_FCAT INTO DATA(LS_FIELDS).
    CONCATENATE LS_FIELDS-FIELDNAME GS_FIELD_LIST INTO GS_FIELD_LIST SEPARATED BY SPACE.
    LS_COMPONENTS-NAME = LS_FIELDS-FIELDNAME.
    SELECT SINGLE ROLLNAME FROM DD03L INTO ( LS_FIELDS-ROLLNAME ) WHERE FIELDNAME = LS_FIELDS-FIELDNAME .
    IF LS_FIELDS-ROLLNAME IS INITIAL .
      DATATYPE ?= CL_ABAP_DATADESCR=>DESCRIBE_BY_DATA(  LS_FIELDS-FIELDNAME ).
      STR  = DATATYPE->ABSOLUTE_NAME.
      SPLIT STR AT '=' INTO STR1 STR2 .
      IF STR2 IS NOT INITIAL .
        LS_FIELDS-ROLLNAME = STR2 .
      ENDIF .
    ENDIF .
    LS_COMPONENTS-TYPE ?= CL_ABAP_ELEMDESCR=>DESCRIBE_BY_NAME( LS_FIELDS-ROLLNAME ) .
    APPEND LS_COMPONENTS TO GS_COMPONENTS.
    APPEND LS_FIELDS-SCRTEXT_M TO GIT_HEADER_TEXT.
  ENDLOOP.
  TRY .
      LR_STRUCT_RESULT = CL_ABAP_STRUCTDESCR=>CREATE( P_COMPONENTS = GS_COMPONENTS ).
      LR_TABLE_RESULT =  CL_ABAP_TABLEDESCR=>CREATE( P_LINE_TYPE  = LR_STRUCT_RESULT ).
    CATCH CX_SY_STRUCT_CREATION.    "
    CATCH CX_SY_TABLE_CREATION.
  ENDTRY.
  CREATE DATA: LRT_TABLE  TYPE HANDLE LR_TABLE_RESULT.
  CREATE DATA: LRS_STRUCT  TYPE HANDLE LR_STRUCT_RESULT.
  DATA LR_REF TYPE REF TO DATA .

  ASSIGN LRT_TABLE->* TO <FS_DYNAMIC_TAB>.
  ASSIGN LRS_STRUCT->* TO <WA_TAB1>.
  DATA : TBX TYPE I .
  DATA : FLAG TYPE C .
  DATA : NEGATIVE TYPE C .
  DATA : VARIABLE TYPE STRING .
  FIELD-SYMBOLS : <VALUE> TYPE ANY .
  FIELD-SYMBOLS : <VALUE_FROM> TYPE ANY .
  DATA : VALUE_FROM TYPE STRING .
  DATA : W_TAB TYPE REF TO DATA .
  DATA: G_TYPE TYPE DD01V-DATATYPE.
  DATA : MINUS  TYPE STRING,
         MINUS1 TYPE STRING.
  """"""""""""""""""""""""""""""""""""filling the internal table """"""""""""""""""""""""""""""""""""""""""""""""""

  LOOP AT  IT_TAB .
    """"""""""""'''''WORKING LOGIC """""""""""""""""""""""
*    CONCATENATE '<WA_TAB1>-' 'REAMT' INTO STR .
*    CONDENSE STR NO-GAPS .
*    ASSIGN (STR) TO <F_ST1> .
*    VARIABLE = '14354618.00-' .
*    IF VARIABLE LT 0 .
*      VARIABLE =   VARIABLE * ( -1 ).
*    ENDIF .
*    ASSIGN VARIABLE TO <WA_AREA>.
*    MOVE <WA_AREA> TO <F_ST1> .
*    UNASSIGN <F_ST1>.
    """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    LOOP AT  GT_FIELDCAT ASSIGNING <WA_TAB> . """""""""""""""field catalog
      IF FLAG <>'X'.
        TBX = 1 .
      ELSE .
        TBX = TBX + 1 .
      ENDIF .
      READ TABLE GT_FIELDCAT INTO WA_FIELDCAT INDEX TBX.
      ASSIGN COMPONENT 'FIELDNAME' OF STRUCTURE <WA_TAB> TO <FIELD>.
      IF <FIELD> IS ASSIGNED.
        CONCATENATE '<WA_TAB1>-'<FIELD> INTO STR1 .
        CONDENSE STR1 NO-GAPS .
        ASSIGN (STR1) TO <VALUE_FROM> .
        ASSIGN COMPONENT <FIELD> OF STRUCTURE IT_TAB TO <F_ST1>.
        V_VALUE = <F_ST1> .
        CONDENSE V_VALUE NO-GAPS .
        IF V_VALUE CA '-'.
          SPLIT V_VALUE AT '-' INTO MINUS MINUS1.
          IF MINUS1 IS INITIAL .
            V_VALUE = V_VALUE * ( -1 ) .
            NEGATIVE = 'X' .
          ENDIF .
        ENDIF .
        MOVE V_VALUE TO <VALUE_FROM> .

        IF NEGATIVE = 'X' .
          <VALUE_FROM> = <VALUE_FROM> * ( -1 ) .
        ENDIF.

      ENDIF .
      FLAG = 'X' .
    ENDLOOP.
    ASSIGN IT_TAB TO <WA_TAB1>.
    APPEND <WA_TAB1> TO <FS_DYNAMIC_TAB>.
  ENDLOOP.

  CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD
    EXPORTING
      FILENAME                = DEFAULT_FILE_PATH
      FILETYPE                = 'ASC'
      WRITE_FIELD_SEPARATOR   = 'X'
      FIELDNAMES              = GIT_HEADER_TEXT
    CHANGING
      DATA_TAB                = <FS_DYNAMIC_TAB>
    EXCEPTIONS
      FILE_WRITE_ERROR        = 1
      NO_BATCH                = 2
      GUI_REFUSE_FILETRANSFER = 3
      INVALID_TYPE            = 4
      NO_AUTHORITY            = 5
      UNKNOWN_ERROR           = 6
      HEADER_NOT_ALLOWED      = 7
      SEPARATOR_NOT_ALLOWED   = 8
      FILESIZE_NOT_ALLOWED    = 9
      HEADER_TOO_LONG         = 10
      DP_ERROR_CREATE         = 11
      DP_ERROR_SEND           = 12
      DP_ERROR_WRITE          = 13
      UNKNOWN_DP_ERROR        = 14
      ACCESS_DENIED           = 15
      DP_OUT_OF_MEMORY        = 16
      DISK_FULL               = 17
      DP_TIMEOUT              = 18
      FILE_NOT_FOUND          = 19
      DATAPROVIDER_EXCEPTION  = 20
      CONTROL_FLUSH_ERROR     = 21
      NOT_SUPPORTED_BY_GUI    = 22
      ERROR_NO_GUI            = 23
      OTHERS                  = 24.

ENDFUNCTION.
1 REPLY 1

FredericGirod
Active Contributor
176

Could you give more detail of the dump ? The dump should give you the variable where the overflow occurs