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: 

Vertical Entries in Database

Former Member
0 Kudos

Hi Experts,

I have a strange Requirement.

i am doing a module pool program in which i have 5 input feilds in which user will make entries and saves to database.

So i have a created a z table and put those 5 feilds on screen in a vertical order.


Now when the user clicks on save button the entries are added to the database in a horizontal manner.

The user wants in a vertica manner as it normally shows in ALV.

IF i am not clear please let me know.

Thanks,

Amit

1 ACCEPTED SOLUTION

saurabh_chikate
Active Participant
0 Kudos

Hi Amit,


The user wants in a vertical manner as it normally shows in ALV.

Please elaborate.

I think you need ALV report in which all 5 field are aligned vertically instead of horizontally

am i correct?

you may need to transpose internal table.

regards,

Saurabh

16 REPLIES 16

saurabh_chikate
Active Participant
0 Kudos

Hi Amit,


The user wants in a vertical manner as it normally shows in ALV.

Please elaborate.

I think you need ALV report in which all 5 field are aligned vertically instead of horizontally

am i correct?

you may need to transpose internal table.

regards,

Saurabh

0 Kudos

Hi Saurabh,

No I dont need a ALV.

i have created ztable with 13 feilds. out of which i have kept 5 feilds on screen for making entry.

now when the user presses save the feilds are getting saved in horizontal manner in database table.

i want those 5 feilds in vertica manner.

0 Kudos

Looks like you want to add each field in new row (vertical manner).

i.e. insert only 1 field in 1 row (other 12 fields blank !?)

     and insert 5 rows like this.

  1. create work area like table
  2. move value from screen field to work area
  3. append work area directly to database.

do steps 2 & 3 for five times.

hope this solves your issue.

Regards,

saurabh

0 Kudos

Hi Saurabh,

I want to add entries in database table like below :

Invoice Type      Document No.                Bill Doc                  Echnage Rate

SEA                        1234                          9000001                10

                                                                9000002                10

                                                                9000003                10

                                                                9000004                10

                                                                9000004                10

so i have done the cding for first 2 feilds like this :

WA_INVTYPE-INVOICE_TYPE = ZTYPE_INVOICES-INVOICE_TYPE.

WA_INVTYPE-BELNR  = ZTYPE_INVOICES-BELNR.

APPEND WA_INVTYPE TO IT_INVTYPE

MODIFY ZTYPE_INVOICES FROM TABLE IT_INVTYPE

and for remaining  feilds as per ur instruction :

        WA_INVTYPE1-CUSTOMINVOICE = ZTYPE_INVOICES-CUSTOMINVOICE.

      APPEND WA_INVTYPE1 TO IT_INVTYPE1.

      CLEAR WA_INVTYPE1.

      WA_INVTYPE1-CUSTOMINVOICE1 = ZTYPE_INVOICES-CUSTOMINVOICE1.

      APPEND WA_INVTYPE1 TO IT_INVTYPE1.

      CLEAR WA_INVTYPE1.

      WA_INVTYPE1-CUSTOMINVOICE2 = ZTYPE_INVOICES-CUSTOMINVOICE2.

      APPEND WA_INVTYPE1 TO IT_INVTYPE1.

      CLEAR WA_INVTYPE1.

      WA_INVTYPE1-CUSTOMINVOICE3 = ZTYPE_INVOICES-CUSTOMINVOICE3.

      APPEND WA_INVTYPE1 TO IT_INVTYPE1.

      CLEAR WA_INVTYPE1.

      WA_INVTYPE1-CUSTOMINVOICE4 = ZTYPE_INVOICES-CUSTOMINVOICE4.

      APPEND WA_INVTYPE1 TO IT_INVTYPE1.

      CLEAR WA_INVTYPE1.

MODIFY ZTYPE_INVOICES FROM TABLE IT_INVTYPE1.

but disried output is not coming.

i have attached the screenshot for you.

Thanks,

Amit

0 Kudos

Dear amit,

Are you sure that you want invoice type field i.e. SEA only once for 5 rows added?

                                                                           

Invoice noDoc noBill DocExchange Rate
SEA1234900000110
9000002
9000003
9000004
9000005

so you are appending data from screen to WA_INVTYPE for 1st row

and appending data for other 4 rows in  WA_INVTYPE1.

if you are able to use debugger please apply breakpoint to

MODIFY ZTYPE_INVOICES FROM TABLE IT_INVTYPE1.


and send your screenshot.


regards ,

saurabh

0 Kudos

Hi Saurabh,

Yes i want invoice type and Doc no. only once as it will be same for all the 5 fields.

all the feilds are there in database but user want to only Bill  Doc no .filds in vertical manner in database.

Attached screenshot of debugger

0 Kudos

Hi amit,

it must be like.

WA_INVTYPE-INVOICE_TYPE = ZTYPE_INVOICES-INVOICE_TYPE.  (sea)

WA_INVTYPE-BELNR  = ZTYPE_INVOICES-BELNR.                              (1234)

WA_INVTYPE-CUSTOMINVOICE = screen field 1.                                  (90001)

WA_INVTYPE-exchange_rate = ZTYPE_INVOICES-exchange_rate           (10)

APPEND WA_INVTYPE TO IT_INVTYPE

CLEAR WA_INVTYPE.

WA_INVTYPE-CUSTOMINVOICE = screen field 2.

APPEND WA_INVTYPE TO IT_INVTYPE.

CLEAR WA_INVTYPE.

WA_INVTYPE-CUSTOMINVOICE = screen field 3.

APPEND WA_INVTYPE TO IT_INVTYPE.

CLEAR WA_INVTYPE.

WA_INVTYPE-CUSTOMINVOICE = screen field 4.

APPEND WA_INVTYPE TO IT_INVTYPE.

CLEAR WA_INVTYPE.

WA_INVTYPE-CUSTOMINVOICE = screen field 5.

APPEND WA_INVTYPE TO IT_INVTYPE.

CLEAR WA_INVTYPE.

MODIFY ZTYPE_INVOICES FROMTABLE IT_INVTYPE.

summery:

append 1 full filled row ti itab

clear work area.

move only screen field 2 to work area.

append

move only screen field 3 to work area.

append

move only screen field 4 to work area.

append

move only screen field 5 to work area.

append

modify ztab from itab.

regards,

saurabh

0 Kudos

Hi Saurabh,

I have got the output like attached in database table.

should i delete reaming 4 feilds from DB and capture all the 5 values in single feilds as it is showing now.

Thanks,

Amit Dwivedi

0 Kudos

should i delete reaming 4 feilds from DB and capture all the 5 values in single feilds as it is showing now.

I cant understand that fully.

are you referring that you want to merge all the bill docs in single row allong with first 3 fields??

0 Kudos

Hi Saurabh,

I want my output as below :

Invoice noDoc noBill DocExchange Rate
SEA1234900000110
9000002
9000003
9000004
9000005

as per ur solution, i have attached the output. all the bill docs are cominng in vertical order under same field i.e. ZTYPE_INVOICES-CUSTOMINVOICE. but remaining 4 feilds are empty in database

  ZTYPE_INVOICES-CUSTOMINVOICE1.

ZTYPE_INVOICES-CUSTOMINVOICE2.

ZTYPE_INVOICES-CUSTOMINVOICE3.

ZTYPE_INVOICES-CUSTOMINVOICE4.

0 Kudos

hi amit,

Can you please draw your Ideal table output in paint with minimum 2 entries

looks like bit of miscommunication is here.

regards,

saurabh

0 Kudos

Hi Saurabh,

Invoice TypeFreight INv NoCustoms Inv NoCustom Exch Rate
Sea12344353453410
3434354511
4353453412
4353453414
5434534512
Sea23456787887810
7876546411
4456653712
5456764814
4536757712

Only point to note is i have 5 different fields for custom invoice in DB like below

custom invoice1

custom invoice2

custom invoice3

custom invoice4

custom invoice5


This is desired output of database table.

Thanks,

Amit Dwivedi

0 Kudos

Hi,

what you need is all 5 inputs inserted in same column.

it is impossible that all entries in table will look in vertical fashion, if thats what you want then i am sorry.

you can concatenate all 5 fields into 1 and then append it.

concatenate scr_fld1 ' ' scr_fld2 ' ' scr_fld3 ' ' scr_fld4 ' ' scr_fld5  INTO screen_input.


and then


WA_INVTYPE-INVOICE_TYPE = ZTYPE_INVOICES-INVOICE_TYPE.  (sea)

WA_INVTYPE-BELNR  = ZTYPE_INVOICES-BELNR.                              (1234)

WA_INVTYPE-CUSTOMINVOICE =  screen_input                                 (90001)

WA_INVTYPE-exchange_rate = ZTYPE_INVOICES-exchange_rate           (10)

APPEND WA_INVTYPE TO IT_INVTYPE

CLEAR WA_INVTYPE.

MODIFY ZTYPE_INVOICES FROMTABLE IT_INVTYPE.


Regards ,

saurabh

kiran_k8
Active Contributor
0 Kudos

Amit,

User will never have access to database tables in Production.Why not develop a LIST report and get the data displayed in whatever the way the User wants.

Either yours or the User's understanding is wrong.

K.Kiran.

Former Member
0 Kudos

Hi Kiran,

yes, i know we have ALV report in which we can have desired output.

But, internally i want like to have output in table above.

just wanted to check whether it is possible or not.

Thanks,

Amit

kiran_k8
Active Contributor
0 Kudos

Amit,

To me it doesn't make any sense and also it is not the way the data gets stored in the database table.

Programatically you can update the table in whatever the way you want but fetching the data back from the table or interpreting it will also remain a challenge.

K.Kiran