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: 

ABAP Table to JSON file

Former Member
0 Kudos

Hi,

i need some Help to transfer internal table to file in JSON format (JavaScript Object Notation) .

i find this link : https://www.sdn.sap.com/irj/scn/wiki?path=/pages/viewpage.action%3fpageid=14260

but what i miss is the select he does there (i need it to follow his code) .

like :

select *

from sflight

and get the structure and then follow all the flow .

another thing is how he declare tab_struct.

if some one with experience can help me with that i appreciate it a lot!

i new to Abap

Regards

1 ACCEPTED SOLUTION

Former Member
0 Kudos

HI Friends,

Any clue ?

Cheers

24 REPLIES 24

former_member181995
Active Contributor
0 Kudos

don't forget You answred to below thread just few days back:

And now you posted the thread on same?!!

0 Kudos

Hi Amit,

This is way into the grey area...

Micheal did say:

>HI,

>i had the same problem

>i think u have to ask who write this code.

>

>Regards

I think it is okay to open a question of his own, unless it is searchable

Many posts don't explain or show the context of the coding which is causing the problem.

This also irritates me to no end sometimes.

I guess there is no easy way out for that in many cases.

Product feature.

Cheers,

Julius

Former Member
0 Kudos

HI Friends,

Any clue ?

Cheers

0 Kudos

Hi Michael

In the link mentioned by you :

Function Modules and it`s code is written.

If you talk about any specific part of the code ,then we can talk through it.

Neha

0 Kudos

HI Nena,

Thank You Very Much for your replay.

if u copy paste his code you get 2 errors ,

1. tab_struct - how to declare it.

2. CASE w_struct-type. (its deriving from 1)

if u understand which Structure he use it can help to debug his code and folow.

Best Regards

0 Kudos

Hi

In the Global data declaration of your function module

Declare this :

TYPES:

Begin of tab_struct,

Fieldname(15) type C,

type type C,

End of tab_struct.

lets see if it s working.

Neha

0 Kudos

HI Neha ,

Thanks,

u now how to declare ?

STRUC

ITAB

zgs_0004

Regards

0 Kudos

HI Nena,

what i add to the code is:

SELECT *

FROM sflight UP TO 10 ROWS

INTO table itab.

and from this point i contnue ,

what i miss is just the declaration of the types i put below

Regards

0 Kudos

Hi Michael

All the code mentioned their is for Function Modules:

These tools will be in the form of Function modules and there will be two versions of each of them , one which can run in all WAS versions and the other which will run from WAS7.0 onwards (using Regular Expressions)

So in your case you have to create the function modules in SE37 in SAP.

Itab and Struct are table parameters of that function module.

zgs_0004 is a structure which was created in SE11 (I guess).

So I am trying to figure out the structure of that while looking into the code of these function modules.

Neha

0 Kudos

HI Neha,

Thanks,

i build 2 fm like he mentioned ,

i see that he do recursion,

and i want to follow but the type declartin is what i miss.

Thanks in Advance .

0 Kudos

Declearation in FM

Itab	LIKE	SFLIGHT

would be enough

0 Kudos

HI Amit,

Thanks ,

this it what exactly i do ,

but some other declartion i miss like:

STRUC

zgs_0004

and what i have to put in tree and struc in export tab after i find there declaration.

Best Regards

0 Kudos

Than Give refrence with zgs_0004

0 Kudos

HI Amit,

Sorry but i don't understand what u mean.

Thanks

0 Kudos

Is Your Z* structure is exist in data dictionary?

It should be.And use this refrence with

Itab         LIKE         <Z structure>

0 Kudos

Hi Amit,

Thanks for your time,

which structure i have to build in se11?

for the example i declare just

itab type SFLIGHT

p.s. maybe my question is stupid ,

i very new to Abap.

Regards

0 Kudos

Hi,

itab type SFLIGHT

itab will the variable in the program and SFILGT is the Database Table .

0 Kudos

Hi Avinash ,

Thanks,

i want to now how to declare :

STRUC

zgs_0004

Regards

0 Kudos

HI,

Go to tcode SE11 and select the radio button and give the zgs_0004 in the corresponing input field and then press on Display button. If the structure exists it will display the Fields of the structure or displays the message structure doesn't exist.

Then this time instead of displaying click on the create button and specify the reuired fields ..the save and active the structure.

0 Kudos

Hi Micheal

ZSY_0004 you have to declare in se11 and then you can refer it in your table parameter.

Neha

0 Kudos

HI Avinash

Thanks,

the important things for me is how he declare STRUC

Another thing is now the type for zgs_0004,

this structure or field? it doesn't exist in my DB,

so i want to guess what the author intend .

hope u can help.

Regards

0 Kudos

Hi Nena,

The important things for me is how to declare STRUC ?

about ZSY_0004 i don't now to what refer it.

AMybe it's structure or field type i don't now.

Regards

0 Kudos

Hi Micheal

If you see the Function module :



FUNCTION z_json_out.
*"----------------------------------------------------------------------
*"*"Interface locale :
*"  IMPORTING
*"     REFERENCE(TREE) TYPE  C OPTIONAL
*"     REFERENCE(STRUC) OPTIONAL

STRUC is declared without any reference in the function module.

Neha

0 Kudos

HI Neha,

Thanks for your help!!!

i soon open a new treat ,

i have more different question for this program ,

hope u can help.

Best Regards