This website is not affiliated with, sponsored by, or approved by SAP AG.

SAP ABAP practice program-help

Development (ABAP Development WorkBench, ABAP/4 programming)

Moderators: Snowy, thx4allthefish, YuriT, Gothmog

SAP ABAP practice program-help

Postby phoenox7 » Tue Jul 15, 2014 2:31 pm

hello,

i am new to the SAP ABAP environment and i am doing a practice exercise.

currently, i am creating a program where a user input (ie: customer #) will be inputted and the output will list the customers list of orders, line items, model part, a years report, etc from the table i will call it from.

Question:
Does this need to be a dynopro in order for all of this to work or does that even matter?

What I know so far(hopefully),
1) open abap editor
2) call the specific table from whichever customer
3) have input from user (not sure how to do this)
4) write the output

Any help is always appreciated and if you need more information please don't hesitate to ask.
phoenox7
 
Posts: 2
Joined: Tue Jul 15, 2014 2:17 pm

Re: SAP ABAP practice program-help

Postby Gothmog » Wed Jul 16, 2014 3:27 am

If you're using the WRITE statement, you don't need a dynpro - the output will be written to a list.
68 74 74 70 3a 2f 2f 74 69 6e 79 75 72 6c 2e 63 6f 6d 2f 62 64 6f 37 6d 77 67
Gothmog
 
Posts: 1943
Joined: Wed Sep 12, 2007 4:46 am
Location: Probably not home

Re: SAP ABAP practice program-help

Postby phoenox7 » Thu Jul 17, 2014 1:15 pm

Hi Gothmog,

I really appreciate your reply and help. I just had a couple more questions if you don't mind.

So far, in ABAP, I've written code(see below) to have a user input to call a customer #(invoice or anything to call all the records of that customer, ie: what they ordered along with the details of that order). That has been a success, but since I am so new to thew ABAP SQL environment, I am not sure if this is working correctly. I am trying to call these specific tables. If you don't mind, could you take a look and see what the issue is?

Here is what I have so far:


Code: Select all
REPORT Assignment_X.


SELECTION-SCREEN BEGIN OF SCREEN 500 TITLE title AS window.
PARAMETERS c_name TYPE i.
SELECTION-SCREEN END OF SCREEN 500.
title = 'Customer #'.
CALL SELECTION-SCREEN '0500' STARTING AT 10 10.

AT SELECTION-SCREEN.
IF c_name IS INITIAL.
MESSAGE 'Enter the customer ID you would like to see' TYPE 'E'.
ENDIF.


START-OF-SELECTION.
IF c_name IS NOT INITIAL.
WRITE: c_name.
ENDIF.

END-OF-SELECTION.

ULINE.


SELECT field
READ TABLE DD03P
WHERE c_name = 2201.


Any help is always appreciated, thanks!
phoenox7
 
Posts: 2
Joined: Tue Jul 15, 2014 2:17 pm

Re: SAP ABAP practice program-help

Postby Gothmog » Fri Jul 18, 2014 3:42 am

A few things:
- you customer number should be defined with the correct type (KNA1-KUNNR). It's not an integer, it's a string of 10 numerical characters, so the internal format of customer number 123 is 0000000123, and that's what you must use for your selections.
Happily, if your screen field is defined with reference to the right format, the external/internal conversion is done automatically.
- you don't need to assign a number (500) to your selection-screen if you only use one, nor do you need to explicitely call it.
By default, selection-screen 1000 will be generated and called.

- DD03P is a structure ( a line format definition), not a table - there's no data to select
- What are you trying to achieve by this?
Code: Select all
SELECT field
READ TABLE DD03P
WHERE c_name = 2201.
Also, in the WHERE clause, the fied name in the table you're reading goes to the left. Even if DD03P was a table, ther's no c_name field in it.
68 74 74 70 3a 2f 2f 74 69 6e 79 75 72 6c 2e 63 6f 6d 2f 62 64 6f 37 6d 77 67
Gothmog
 
Posts: 1943
Joined: Wed Sep 12, 2007 4:46 am
Location: Probably not home

Re: SAP ABAP practice program-help

Postby Grogan » Sun Jul 20, 2014 3:50 pm

What Gothmog is gently suggesting is that you don't need all that messy screen handling. Instead your input field should be defined something like:
Code: Select all
parameters:
  p_kunnr                    type kna1-kunnr.

Then in the editor: Goto -> Text Elements -> Selection Texts to define the screen label.

Doing it this way:
  • Is concise and simple.
  • The input field is defined with its correct type and length and with automatic input conversion.
  • It provides the user with PF1 input help.
  • It provides the user with PF4 input value selection, so that the user can search for existing customers by name, company, address etc.
To read customer data you need something like:
Code: Select all
data:
  ls_lfa1                    type lfa1.

select single *
  from lfa1
  into ls_lfa1
  where kunnr eq p_kunnr.

And then you can WRITE values from your internal data area ls_lfa1.

Of course if you want to read multiple customers, replace the PARAMETERS statement with SELECT-OPTIONS, and in the SELECT statement remove keyword SINGLE and read INTO TABLE lt_lfa1.

Cheers,
Grogan

Award cash if useful.
Grogan
 
Posts: 365
Joined: Thu Aug 04, 2005 7:16 pm
Location: Australia

Re: SAP ABAP practice program-help

Postby Gothmog » Mon Jul 21, 2014 3:30 am

Obviously, Grogan meant:
Code: Select all
data:
  ls_kna1                    type kna1.

select single *
  from kna1
  into ls_kna1
  where kunnr eq p_kunnr.
68 74 74 70 3a 2f 2f 74 69 6e 79 75 72 6c 2e 63 6f 6d 2f 62 64 6f 37 6d 77 67
Gothmog
 
Posts: 1943
Joined: Wed Sep 12, 2007 4:46 am
Location: Probably not home

Re: SAP ABAP practice program-help

Postby Grogan » Mon Jul 21, 2014 4:25 pm

D'oh! Thanks for the correction Gothmog. I mixed my Vendors with my Customers. :oops:
Grogan

Award cash if useful.
Grogan
 
Posts: 365
Joined: Thu Aug 04, 2005 7:16 pm
Location: Australia


Return to ABAP

Who is online

Users browsing this forum: No registered users and 7 guests





This website is not affiliated with, sponsored by, or approved by SAP AG.