Skip to Content
-3
Jul 28 at 11:36 AM

JSON FILE

46 Views

I have data in internal table and download the file to excel file. How the abap internal data transformed to JSON file.

What is exact concept for XML TO JSON OR excel to JSON.

The following code need to change to JSON format...

REPORT Z69.

TYPE-POOLS:SLIS.
DATA:GT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
GT_EVENT TYPE SLIS_T_EVENT,
WA_EVENT TYPE SLIS_ALV_EVENT,
GT_EVENT_T TYPE SLIS_T_EVENT,
WA_EVENT_T TYPE SLIS_ALV_EVENT,
GT_LAYOUT TYPE SLIS_LAYOUT_ALV,
GT_SORT TYPE SLIS_T_SORTINFO_ALV,
WA_SORT TYPE SLIS_SORTINFO_ALV.
DATA: G_SAVE TYPE C VALUE 'A'.
DATA: GX_VARIANT TYPE DISVARIANT.


TYPES:BEGIN OF TY_MARA,
MATNR TYPE MATNR,
MTART TYPE MARA-MTART,
MBRSH TYPE MARA-MBRSH,
MEINS TYPE MARA-MEINS,
END OF TY_MARA.

DATA:IT_MARA TYPE STANDARD TABLE OF TY_MARA,
WA_MARA TYPE TY_MARA.

INITIALIZATION.
CLEAR:WA_MARA.
REFRESH:IT_MARA.

START-OF-SELECTION.

SELECT MATNR MTART MBRSH MEINS FROM MARA INTO TABLE IT_MARA UP TO 100 ROWS WHERE MTART = 'ZFRT'.
IF SY-SUBRC = 0.
SORT IT_MARA BY MATNR.
ENDIF.

END-OF-SELECTION.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_MARA'.
WA_FIELDCAT-FIELDNAME = 'MATNR'.
WA_FIELDCAT-SELTEXT_M = 'Material'.
APPEND WA_FIELDCAT TO GT_FIELDCAT.

CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_MARA'.
WA_FIELDCAT-FIELDNAME = 'MTART'.
WA_FIELDCAT-SELTEXT_M = 'Material Type'.
APPEND WA_FIELDCAT TO GT_FIELDCAT.

CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_MARA'.
WA_FIELDCAT-FIELDNAME = 'MBRSH'.
WA_FIELDCAT-SELTEXT_M = 'Industry Sector'.
APPEND WA_FIELDCAT TO GT_FIELDCAT.

CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_MARA'.
WA_FIELDCAT-FIELDNAME = 'MEINS'.
WA_FIELDCAT-SELTEXT_M = 'Units'.
APPEND WA_FIELDCAT TO GT_FIELDCAT.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER = ' '
* I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = SY-REPID
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
* I_CALLBACK_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_END_OF_LIST = ' '
* I_STRUCTURE_NAME =
* I_BACKGROUND_ID = ' '
* I_GRID_TITLE =
* I_GRID_SETTINGS =
IS_LAYOUT = GT_LAYOUT
IT_FIELDCAT = GT_FIELDCAT[]
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
I_SAVE = G_SAVE
IS_VARIANT = GX_VARIANT
IT_EVENTS = GT_EVENT[]
* IT_EVENT_EXIT =
* IS_PRINT =
* IS_REPREP_ID =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* I_HTML_HEIGHT_TOP = 0
* I_HTML_HEIGHT_END = 0
* IT_ALV_GRAPHICS =
* IT_HYPERLINK =
* IT_ADD_FIELDCAT =
* IT_EXCEPT_QINFO =
* IR_SALV_FULLSCREEN_ADAPTER =
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = IT_MARA[]
* EXCEPTIONS
* PROGRAM_ERROR = 1
* OTHERS = 2
.