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: 

re:radio buttons

Former Member
0 Kudos

Hi abap gurus,

I have created 3 radio buttons i.e p_pre ,p_swa and

p_shi.

P-pre is defualt.(active)

if P-swa is active posting date must be filled in(s-options).

if P-pre is not active,comany code bukrs must be filled in.

pls write some code regarding the same.

Thanks in advance,

Prerna.

3 REPLIES 3

Former Member
0 Kudos

Hi,

i am sending sample code just gothrough

Report

  • TABLES

*----


TABLES: likp, "SD Document: Delivery Header Data

z194a, "BRI Delivery Download User History Table

usr03, "User address data

kna1, "General data in customer master

tvstt, "Organizational Unit: Shipping Points: Texts

vbrk, "Billing: Header Data

konp, "Conditions (Item)

a005, "Customer/Material

vkdfs, "SD Index: Billing Initiator

vbak, "Sales Document: Header Data

ekbe, "PO History

t001w, "Plants/Branches

ekpo. "PO Line

*----


  • DATA - CONSTANTS

*----


CONSTANTS: c_space(1) TYPE c VALUE ' ',

c_eqsign(1) TYPE c VALUE '=',

c_quotes(1) TYPE c VALUE '"'.

*----


  • DATA - WORKING VARIABLES

*----


DATA: w_answer(1) TYPE c,

w_answer_billing(1) TYPE c,

w_excel_file LIKE rlgrap-filename,

w_arktx(1584) TYPE c,

w_time(8) TYPE c,

w_name LIKE usr03-name1,

w_even TYPE i VALUE 0,

w_count TYPE i VALUE 0,

w_text_name LIKE thead-tdname,

w_maxlz LIKE marc-maxlz,

w_lzeih LIKE marc-lzeih,

w_maxlz_days(7) TYPE n,

w_mndat TYPE d,

w_shelf_flag TYPE c,

w_vtweg LIKE lips-vtweg,

w_header(1) TYPE c,

w_del_billed(1) TYPE c,

w_ean11 LIKE mara-ean11,

w_ntgew LIKE mara-ntgew,

w_brgew LIKE lips-brgew,

w_mfrgr LIKE marc-mfrgr,

w_stawn LIKE marc-stawn,

w_herkl LIKE marc-herkl.

*----


  • DATA - INTERNAL TABLES AND FIELD LISTS

*----


  • delivery header table

DATA: BEGIN OF t_likp OCCURS 0,

vkorg LIKE likp-vkorg,

kunnr LIKE likp-kunnr,

vstel LIKE likp-vstel,

vbeln LIKE likp-vbeln,

vgbel LIKE lips-vgbel,

lfdat LIKE likp-lfdat,

wadat_ist LIKE likp-wadat_ist,

kodat LIKE likp-kodat,

kunag LIKE likp-kunag,

END OF t_likp.

  • delivery item table with batch and billing details

DATA: BEGIN OF t_lips OCCURS 0,

bstnk LIKE vbak-bstnk,"Customer purchase order number

kunag LIKE vbrk-kunag,"Sold-to party

vgbel LIKE lips-vgbel,"Document number of the reference document

vbeln LIKE lips-vbeln,"Delivery

vbelnbil LIKE vbrk-vbeln,"Billing Document

fkdat LIKE vbrk-fkdat,"Billing date for billing index and printout

posnr LIKE lips-posnr,"Delivery item

matnr LIKE lips-matnr,"Material Number

kdmat LIKE lips-kdmat,"Material belonging to the customer

arktx(1584) TYPE c,

lfimg LIKE lips-lfimg,"Actual quantity delivered (in sales units)

kbetr LIKE konp-kbetr,"Rate (condition amount or percentage) where no scale exists

netwr LIKE vbrk-netwr,"Net value in document currency

konwa LIKE konp-konwa,"Rate unit (currency or percentage)

lfdat LIKE likp-lfdat,"Delivery Date

charg TYPE charg_d, "Batch Number

vfdat LIKE mch1-vfdat,"Shelf Life Expiration Date

mndat(16) TYPE c,

*Fields for the data from tables MARA & MARC

ean11(19) TYPE c,

ntgew LIKE mara-ntgew,"Net weight

brgew LIKE lips-brgew,"Gross weight

mfrgr(11) TYPE c,

stawn(20) TYPE c,

herkl LIKE marc-herkl,"Country of origin of the material

totnw LIKE lips-lfimg,"Actual quantity delivered (in sales units)

totgw LIKE lips-lfimg,"Actual quantity delivered (in sales units)

vtweg LIKE lips-vtweg,"Distribution Channel

uecha LIKE lips-uecha,"Higher-level item of batch split item

kcmeng LIKE lips-kcmeng,"Cumulative batch quantity of all split items (in StckUnit)

werks LIKE lips-werks,"Plant

wrkst LIKE mara-wrkst,"Basic Material

END OF t_lips.

DATA: BEGIN OF t_lips_both OCCURS 0,

bstnk LIKE vbak-bstnk, "Customer purchase order number

kunag LIKE vbrk-kunag, "Sold-to party

vgbel LIKE lips-vgbel, "Document number of the reference document

vbeln LIKE lips-vbeln, "Delivery

vbelnbil LIKE vbrk-vbeln, "Billing Document

fkdat LIKE vbrk-fkdat, "Billing date for billing index and printout

posnr LIKE lips-posnr, "Delivery item

matnr LIKE lips-matnr, "Material Number

kdmat LIKE lips-kdmat, "Material belonging to the customer

arktx(1584) TYPE c,

lfimg LIKE lips-lfimg, "Actual quantity delivered (in sales units)

kbetr LIKE konp-kbetr, "Rate (condition amount or percentage) where no scale exists

netwr LIKE vbrk-netwr, "Net value in document currency

konwa LIKE konp-konwa, "Rate unit (currency or percentage)

lfdat LIKE likp-lfdat, "Delivery Date

charg TYPE charg_d, "Batch Number

vfdat LIKE mch1-vfdat, "Shelf Life Expiration Date

mndat(16) TYPE c,

*Fields for the data from tables MARA & MARC

ean11(19) TYPE c,

ntgew LIKE mara-ntgew, "Net weight

brgew LIKE lips-brgew, "Gross weight

mfrgr(11) TYPE c,

stawn(20) TYPE c,

herkl LIKE marc-herkl, "Country of origin of the material

totnw LIKE lips-lfimg, "Actual quantity delivered (in sales units)

totgw LIKE lips-lfimg, "Actual quantity delivered (in sales units)

wrkst LIKE mara-wrkst, "Basic Material

END OF t_lips_both.

  • delivery item table without batch or billing details

DATA: BEGIN OF t_lips_no_batch_no_bill OCCURS 0,

vgbel LIKE lips-vgbel, "Document number of the reference document

vbeln LIKE lips-vbeln, "Delivery

posnr LIKE lips-posnr, "Delivery item

matnr LIKE lips-matnr, "Material Number

kdmat LIKE lips-kdmat, "Material belonging to the customer

arktx(1584) TYPE c,

lfimg LIKE lips-lfimg, "Actual quantity delivered (in sales units)

lfdat LIKE likp-lfdat, "Delivery Date

END OF t_lips_no_batch_no_bill.

  • delivery item table with batch details but no billing_details

DATA: BEGIN OF t_lips_with_batch OCCURS 0,

vgbel LIKE lips-vgbel, "Document number of the reference document

vbeln LIKE lips-vbeln, "Delivery

posnr LIKE lips-posnr, "Delivery item

matnr LIKE lips-matnr, "Material Number

kdmat LIKE lips-kdmat, "Material belonging to the customer

arktx(1584) TYPE c,

lfimg LIKE lips-lfimg, "Actual quantity delivered (in sales units)

lfdat LIKE likp-lfdat, "Delivery Date

charg LIKE lips-charg, "Batch Number

vfdat LIKE mch1-vfdat, "Shelf Life Expiration Date

mndat(16) TYPE c,

wrkst LIKE mara-wrkst, ""Basic Material

END OF t_lips_with_batch.

  • delivery item table with billing details and no batch details.

DATA: BEGIN OF t_lips_with_bill OCCURS 0,

bstnk LIKE vbak-bstnk, "Customer purchase order number

kunag LIKE vbrk-kunag, "Sold-to party

vgbel LIKE lips-vgbel, "Document number of the reference document

vbeln LIKE lips-vbeln, "Delivery

vbelnbil LIKE vbrk-vbeln, "Billing Document

fkdat LIKE vbrk-fkdat, "Billing date for billing index and printout

posnr LIKE lips-posnr, "Delivery item

matnr LIKE lips-matnr, "Material Number

kdmat LIKE lips-kdmat, "Material belonging to the customer

arktx(1584) TYPE c,

lfimg LIKE lips-lfimg, "Actual quantity delivered (in sales units)

kbetr LIKE konp-kbetr, "Rate (condition amount or percentage) where no scale exists

netwr LIKE vbrk-netwr, "Net value in document currency

konwa LIKE konp-konwa, "Rate unit (currency or percentage)

lfdat LIKE likp-lfdat, "Delivery Date

  • Fields for the details from MARA & MARC

ean11(19) TYPE c,

ntgew LIKE mara-ntgew, "Net weight

brgew LIKE lips-brgew, "Gross weight

mfrgr(11) TYPE c,

stawn(20) TYPE c,

herkl LIKE marc-herkl, "Country of origin of the material

totnw LIKE lips-lfimg, "Actual quantity delivered (in sales units)

totgw LIKE lips-lfimg, "Actual quantity delivered (in sales units)

END OF t_lips_with_bill.

DATA: BEGIN OF t_vbrp OCCURS 0,

vbeln LIKE vbrp-vbeln, "Billing Document

prsdt LIKE vbrp-prsdt, "Date for pricing and exchange rate

vrkme LIKE vbrp-vrkme, "Sales unit

vbtyp LIKE vbak-vbtyp, "SD document category

netwr LIKE vbrp-netwr, "Net Weight

fkimg LIKE vbrp-fkimg, "Actual Invoiced Quantity

posnr LIKE vbrp-posnr, "Item

END OF t_vbrp.

DATA: BEGIN OF t_vbrp_temp OCCURS 0,

vbeln LIKE vbrp-vbeln, "Billing Document

netwr LIKE vbrp-netwr, "Net Weight

fkimg LIKE vbrp-fkimg, ""Actual Invoiced Quantity

END OF t_vbrp_temp.

  • download details

DATA: BEGIN OF t_z194a OCCURS 0.

INCLUDE STRUCTURE z194a.

DATA: END OF t_z194a.

  • column headings

DATA: BEGIN OF t_fieldnames OCCURS 0,

name LIKE dbfield-name,

END OF t_fieldnames.

  • text lines

DATA: BEGIN OF t_lines OCCURS 0.

INCLUDE STRUCTURE tline.

DATA: END OF t_lines.

DATA: BEGIN OF t_header.

INCLUDE STRUCTURE thead.

DATA: END OF t_header.

DATA : BEGIN OF wa_lips,

matnr LIKE mara-matnr, "Material Number

vkorg LIKE likp-vkorg, "Sales Organization

vtweg LIKE lips-vtweg, "Distribution Channel

END OF wa_lips.

*----


  • SELECTION SCREEN

*----


SELECTION-SCREEN SKIP 2.

  • customer number and shipping point

PARAMETERS: p_kunnr LIKE likp-kunnr MATCHCODE OBJECT debi OBLIGATORY,

p_vstel LIKE likp-vstel OBLIGATORY.

SELECTION-SCREEN SKIP 1.

  • delivery date and delivery number

SELECTION-SCREEN BEGIN OF BLOCK a1 WITH FRAME TITLE text-001.

SELECT-OPTIONS: s_lfdat FOR likp-lfdat.

SELECT-OPTIONS: s_vbeln FOR likp-vbeln.

SELECTION-SCREEN END OF BLOCK a1.

  • sort order and extract batch flag

SELECTION-SCREEN BEGIN OF BLOCK a2 WITH FRAME TITLE text-023.

SELECTION-SCREEN SKIP 1.

SELECTION-SCREEN BEGIN OF BLOCK a3 WITH FRAME TITLE text-024.

PARAMETERS: p_gidat RADIOBUTTON GROUP rbut DEFAULT 'X',

p_order RADIOBUTTON GROUP rbut.

SELECTION-SCREEN END OF BLOCK a3.

SELECTION-SCREEN SKIP 1.

SELECTION-SCREEN BEGIN OF BLOCK a4 WITH FRAME TITLE text-032.

SKIP 1.

PARAMETERS: p_nether RADIOBUTTON GROUP down DEFAULT 'X',

p_batch RADIOBUTTON GROUP down,

p_bill RADIOBUTTON GROUP down,

p_both RADIOBUTTON GROUP down.

SELECTION-SCREEN END OF BLOCK a4.

SELECTION-SCREEN SKIP 1.

SELECTION-SCREEN END OF BLOCK a2.

************************************************************************

                                                                • MAIN PROGRAM **************************

************************************************************************

*----


INITIALIZATION.

*----


*----


START-OF-SELECTION.

*----


  • set the status

SET PF-STATUS 'DLVLIST'.

  • select deliveries

PERFORM select_deliveries.

  • display the list of deliveries

PERFORM display_list.

*----


END-OF-SELECTION.

*----


*----


AT USER-COMMAND.

*----


  • if user selects download button, download delivery

CASE sy-ucomm.

WHEN 'DLEX'.

PERFORM download_delivery.

ENDCASE.

*----


AT LINE-SELECTION.

*----


  • if user doubleclicks a line run transaction display delivery VL03

SET PARAMETER ID 'VL ' FIELD t_likp-vbeln.

CALL TRANSACTION 'VL03' AND SKIP FIRST SCREEN.

************************************************************************

                                                                  • SUBROUTINES **************************

************************************************************************

&----


*& Form SELECT_DELIVERIES

&----


  • select deliveries

----


  • --> p1 text

  • <-- p2 text

----


FORM select_deliveries.

  • select post goods issued deliveries for customer, shipping point and

  • dates

CLEAR t_likp.

REFRESH t_likp.

SELECT * INTO CORRESPONDING FIELDS OF TABLE t_likp

FROM likp

WHERE kunnr EQ p_kunnr

AND vstel EQ p_vstel

AND lfdat IN s_lfdat

AND vbeln IN s_vbeln

AND wadat_ist NE 0.

  • if no deliveries found, display an error message and exit

IF sy-subrc NE 0.

MESSAGE i420(vr).

STOP.

ENDIF.

  • get order number for delivery - assumes only one order per delivery

LOOP AT t_likp.

SELECT SINGLE vgbel FROM lips

INTO t_likp-vgbel

WHERE vbeln EQ t_likp-vbeln.

  • if sold-to customer is blank, the delivery comes from a stock

  • transport order which means that the sold-to customer number has

  • to be retrieved from the plant/branches table.

  • the PO history table has to be read to find the PO number from the

  • delivery. The delivering plant has to be found from the PO line

*( there will only ever be one plant per PO) and then the plant/

  • branches table has to be read to find the sold-to customer.

  • that customer is stored in the internal table and later used to

  • read the CMIR partner number and the CMIR text.

******************************

IF t_likp-kunag EQ space.

  • read PO history table

SELECT SINGLE * FROM ekbe

WHERE xblnr EQ t_likp-vbeln.

IF sy-subrc EQ 0.

  • read PO line table

SELECT SINGLE * FROM ekpo

WHERE ebeln EQ ekbe-ebeln.

IF sy-subrc EQ 0.

  • read plant/branches table

SELECT SINGLE * FROM t001w

WHERE werks EQ ekpo-werks.

IF sy-subrc EQ 0.

t_likp-kunag = t001w-kunnr.

ENDIF.

ENDIF.

ENDIF.

ENDIF.

MODIFY t_likp.

ENDLOOP.

ENDFORM. " SELECT_DELIVERIES

&----


*& Form DISPLAY_LIST

&----


  • display list of deliveries for selected customer

----


  • --> p1 text

  • <-- p2 text

----


FORM display_list.

*display the list of deliveries for the selected customer and

*shipping point

  • sort by goods issue date or order number

IF p_gidat EQ 'X'.

SORT t_likp BY wadat_ist DESCENDING.

ELSE.

SORT t_likp BY vgbel ASCENDING.

ENDIF.

  • select customer name from customer table

SELECT SINGLE * FROM kna1

WHERE kunnr EQ p_kunnr.

  • select shipping point text from text table

SELECT SINGLE * FROM tvstt

WHERE vstel EQ p_vstel

AND spras EQ sy-langu.

  • write customer and selection details

WRITE: /1 text-002, 25 p_kunnr, 45 kna1-name1.

WRITE: /1 text-003, 25 p_vstel, 45 tvstt-vtext.

SKIP 1.

WRITE: /1 text-008, 25 s_lfdat-low, text-009, s_lfdat-high.

SKIP 2.

  • write header line

WRITE: /1 text-022, 25 text-026, 40 text-005, 55 text-006,

90 text-007, 110 text-021.

WRITE: /25 text-027, 40 text-028, 55 text-029, 110 text-025.

ULINE.

  • write details

LOOP AT t_likp.

  • switch colour for stripes (same colour for all lines for a delivery)

w_even = w_count MOD 2.

IF w_even EQ 0.

FORMAT COLOR COL_NORMAL INTENSIFIED OFF.

ELSE.

FORMAT COLOR COL_NORMAL INTENSIFIED ON.

ENDIF.

ADD 1 TO w_count.

  • select and sort download history.

CLEAR t_z194a.

REFRESH t_z194a.

SELECT * INTO CORRESPONDING FIELDS OF TABLE t_z194a

FROM z194a

WHERE vbeln EQ t_likp-vbeln.

SORT t_z194a BY dload_date DESCENDING dload_time DESCENDING.

  • write first line up to goods issue date.

WRITE: /1 t_likp-vgbel, 25 t_likp-vbeln, 40 t_likp-wadat_ist.

  • Hide t_likp-kunag

HIDE: t_likp-vbeln, t_likp-lfdat, t_likp-vkorg, t_likp-kunag.

  • select user name

LOOP AT t_z194a.

MOVE t_z194a-dload_time TO w_time.

SELECT SINGLE * FROM usr03

WHERE bname EQ t_z194a-uname.

IF usr03-name1 NE space.

MOVE usr03-name1 TO w_name.

ELSE.

MOVE t_z194a-uname TO w_name.

ENDIF.

IF sy-tabix EQ 1.

WRITE: 55 w_name, 90 t_z194a-dload_date,

110 w_time USING EDIT MASK '__:__:__'.

ELSE.

WRITE: /55 w_name, 90 t_z194a-dload_date,

110 w_time USING EDIT MASK '__:__:__'.

HIDE: t_likp-vbeln, t_likp-lfdat, t_likp-vkorg, t_likp-kunag.

ENDIF.

ENDLOOP.

ENDLOOP.

CLEAR t_likp.

ENDFORM. " DISPLAY_LIST

&----


*& Form DOWNLOAD_DELIVERY

&----


  • download delivery

----


  • --> p1 text

  • <-- p2 text

----


FORM download_delivery.

DATA: v_textid TYPE rstxt-tdname.

DATA : w_temp1(20) TYPE c,

w_cp(1) TYPE c,

w_temp2(20) TYPE c.

CLEAR: t_lips,

t_lips_no_batch_no_bill,

t_lips_with_batch,

t_lips_with_bill.

REFRESH: t_lips,

t_lips_no_batch_no_bill,

t_lips_with_batch,

t_lips_with_bill.

IF t_likp-vbeln EQ space.

MESSAGE i370.

ELSE.

CALL FUNCTION 'POPUP_TO_CONFIRM'

EXPORTING

titlebar = text-063

text_question = text-072

text_button_1 = text-070

text_button_2 = text-071

default_button = '2'

display_cancel_button = 'X'

start_column = 25

start_row = 6

IMPORTING

answer = w_answer

EXCEPTIONS

text_not_found = 1

OTHERS = 2.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

  • if user confirms download, select data for download

IF w_answer EQ '1'.

*Check :If the user has selected include billing details look to see

*if the delivery has been billed.

IF p_both = 'X' OR p_bill = 'X'.

*Check to see if the delivery has been billed.

CLEAR w_del_billed.

SELECT SINGLE *

FROM vkdfs

WHERE vkorg EQ t_likp-vkorg

AND kunnr EQ t_likp-kunag

AND vbeln EQ t_likp-vbeln.

IF sy-subrc EQ 0.

*confirm that download should go ahead as delivery has not been

*billed.

CALL FUNCTION 'POPUP_TO_CONFIRM'

EXPORTING

titlebar = text-063

text_question = text-073

text_button_1 = text-070

text_button_2 = text-071

default_button = '2'

display_cancel_button = 'X'

start_column = 25

start_row = 6

IMPORTING

answer = w_answer_billing

EXCEPTIONS

text_not_found = 1

OTHERS = 2.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

ELSE.

w_answer_billing = '1'.

w_del_billed = 'Y'.

ENDIF.

ELSE.

w_answer_billing = '1'.

ENDIF. "no billing details req

*Check to see if w_anwser = 'J'. If popup not called w_answer will be

  • 'J' from the previous pop up.

IF w_answer_billing = '1'.

*select lines on the delivery

SELECT * INTO CORRESPONDING FIELDS OF TABLE t_lips

FROM lips

WHERE vbeln EQ t_likp-vbeln.

  • check each line: if batch details are required delete the header line

  • for for batch splits, if batch details are not required delete the

  • batch split lines.

LOOP AT t_lips.

IF ( p_bill EQ 'X' OR p_nether EQ 'X' )

AND t_lips-uecha NE 0.

DELETE t_lips.

ELSEIF ( p_batch EQ 'X' OR p_both = 'X' )

AND t_lips-kcmeng NE 0.

DELETE t_lips.

ELSE.

MOVE t_likp-lfdat TO t_lips-lfdat.

IF t_lips-kcmeng NE 0.

MOVE t_lips-kcmeng TO t_lips-lfimg.

ENDIF.

*--- move the customer name to T_LIKP-customer

MOVE t_likp-kunag TO t_lips-kunag.

  • get the customer material number

SELECT SINGLE kdmat INTO t_lips-kdmat

FROM knmt

WHERE vkorg EQ t_likp-vkorg

AND vtweg EQ t_lips-vtweg

AND kunnr EQ t_likp-kunag

AND matnr EQ t_lips-matnr.

  • get the custmer basic material.

SELECT SINGLE wrkst FROM mara INTO t_lips-wrkst

WHERE matnr EQ t_lips-matnr.

  • get the invoice no invoice date invoice price invoice currency

SELECT SINGLE : vbeln erdat rfwrt waers FROM vbfa INTO

(t_lips-vbelnbil, t_lips-fkdat,

t_lips-netwr, t_lips-konwa )

WHERE vbelv EQ t_lips-vgbel

AND vbtyp_n EQ 'M'.

  • Retrieving the CMIR Text.

CLEAR: w_text_name,

wa_lips.

***********************************

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

input = t_likp-kunag

IMPORTING

output = t_likp-kunag.

v_textid+0(4) = t_likp-vkorg.

v_textid+4(2) = t_lips-vtweg.

v_textid+6(10) = t_likp-kunag.

v_textid+16(18) = t_lips-matnr.

CLEAR w_arktx.

************************************

CALL FUNCTION 'READ_TEXT'

EXPORTING

client = sy-mandt

id = '0001'

language = sy-langu

name = v_textid

object = 'KNMT'

IMPORTING

header = t_header

TABLES

lines = t_lines

EXCEPTIONS

id = 1

language = 2

name = 3

not_found = 4

object = 5

reference_check = 6

wrong_access_to_archive = 7

OTHERS = 8.

IF sy-subrc EQ 0.

LOOP AT t_lines.

CONCATENATE w_arktx t_lines-tdline INTO w_arktx

SEPARATED BY space.

ENDLOOP.

ENDIF.

IF w_arktx NE space.

MOVE w_arktx+1(1583) TO t_lips-arktx.

ELSEIF w_arktx EQ space.

CLEAR w_text_name.

***********************************

CLEAR v_textid.

wa_lips-matnr = t_lips-matnr.

wa_lips-vkorg = t_likp-vkorg.

wa_lips-vtweg = t_lips-vtweg.

w_text_name = wa_lips.

CLEAR w_arktx.

***********************************

  • Retrieval of Sales Text

CALL FUNCTION 'READ_TEXT'

EXPORTING

client = sy-mandt

id = '0001'

language = sy-langu

name = w_text_name

object = 'MVKE'

IMPORTING

header = t_header

TABLES

lines = t_lines

EXCEPTIONS

id = 1

language = 2

name = 3

not_found = 4

object = 5

reference_check = 6

wrong_access_to_archive = 7

OTHERS = 8.

IF sy-subrc EQ 0.

LOOP AT t_lines.

CONCATENATE w_arktx t_lines-tdline INTO w_arktx

SEPARATED BY space.

ENDLOOP.

ENDIF.

IF w_arktx NE space.

MOVE w_arktx+1(1583) TO t_lips-arktx.

ELSE.

  • Retrieving the 40 Char Material Text from MAKT table.

SELECT SINGLE maktx INTO (w_arktx) FROM makt

WHERE matnr = t_lips-matnr

AND spras = sy-langu.

IF sy-subrc EQ 0.

MOVE w_arktx TO t_lips-arktx.

ENDIF.

ENDIF.

ENDIF.

  • select batch details if required

IF p_both EQ 'X' OR p_batch EQ 'X'.

SELECT SINGLE vfdat INTO CORRESPONDING FIELDS OF t_lips

FROM mch1

WHERE matnr EQ t_lips-matnr

AND charg EQ t_lips-charg.

  • extract maximum storage period from t_marc

SELECT SINGLE maxlz lzeih

INTO (w_maxlz,w_lzeih)

FROM marc

WHERE matnr EQ t_lips-matnr

AND werks EQ t_lips-werks.

  • check if w_maxlz is in days, if not convert to days.

w_shelf_flag = 'N'.

CLEAR w_maxlz_days.

PERFORM convert_unit_measure USING w_lzeih

w_maxlz

CHANGING w_maxlz_days

w_shelf_flag.

  • calculate date of manufacture.

IF w_maxlz_days NE 0 AND w_shelf_flag = 'N'.

w_mndat = t_lips-vfdat - w_maxlz_days.

*check date of manufacture is after the date of picking.

READ TABLE t_likp WITH KEY vbeln = t_lips-vbeln.

IF t_likp-kodat < w_mndat.

MOVE text-004 TO t_lips-mndat.

ELSE.

WRITE w_mndat TO t_lips-mndat

USING EDIT MASK '"__.__.____"'.

ENDIF.

ELSEIF w_maxlz_days = 0 AND w_shelf_flag = 'Y'.

MOVE text-004 TO t_lips-mndat.

ELSE.

MOVE text-034 TO t_lips-mndat.

ENDIF.

ENDIF.

  • Get billing details.

IF p_both EQ 'X' OR p_bill EQ 'X'.

  • Get the Material Details from MARA

SELECT SINGLE ean11 ntgew brgew

FROM mara

INTO (w_ean11,w_ntgew,w_brgew)

WHERE matnr = t_lips-matnr.

IF sy-subrc EQ 0.

CONCATENATE c_eqsign c_quotes w_ean11 c_quotes INTO t_lips-ean11.

MOVE w_ntgew TO t_lips-ntgew.

MOVE w_brgew TO t_lips-brgew.

ENDIF.

  • Determinationf of Total Net Weight & Gross Weight,here Netweight and

  • Gross weight are multiplied by the Quantity for each line.

t_lips-totnw = t_lips-lfimg * t_lips-ntgew.

t_lips-totgw = t_lips-lfimg * t_lips-brgew.

MODIFY t_lips.

  • Get the Details from MARC table

SELECT SINGLE mfrgr stawn herkl

FROM marc

INTO (w_mfrgr,w_stawn,w_herkl)

WHERE matnr = t_lips-matnr

AND werks = t_lips-werks.

IF sy-subrc EQ 0.

CONCATENATE c_eqsign c_quotes w_mfrgr c_quotes INTO t_lips-mfrgr.

CONCATENATE c_eqsign c_quotes w_stawn c_quotes INTO t_lips-stawn.

MOVE w_herkl TO t_lips-herkl.

ENDIF.

MODIFY t_lips.

CLEAR : w_ean11,w_ntgew,w_brgew,w_mfrgr,w_stawn,w_herkl.

*--- Invoice Price and Invoice Value

  • Get the Customer Purchase order number

SELECT SINGLE *

FROM vbak

WHERE vbeln = t_lips-vgbel.

IF sy-subrc = 0.

MOVE vbak-bstnk TO t_lips-bstnk.

ENDIF.

  • Get billing details.

IF w_answer_billing = 1 AND w_del_billed = 'Y'.

SELECT *

FROM vbrp

INTO CORRESPONDING FIELDS OF TABLE t_vbrp

WHERE vgbel = t_lips-vbeln

AND vgpos = t_lips-posnr.

LOOP AT t_vbrp.

SELECT SINGLE vbtyp

INTO t_vbrp-vbtyp

FROM vbrk

WHERE vbeln = t_vbrp-vbeln.

IF t_vbrp-vbtyp NE '5' AND t_vbrp-vbtyp NE 'M'.

DELETE t_vbrp.

ELSE.

MODIFY t_vbrp.

ENDIF.

CLEAR t_vbrp.

ENDLOOP.

SORT t_vbrp BY vbeln DESCENDING.

****************************************************************

READ TABLE t_vbrp INDEX 1.

  • Get sold-to customer details

SELECT SINGLE * FROM vbrk WHERE vbeln = t_vbrp-vbeln.

IF sy-subrc EQ 0.

MOVE vbrk-kunag TO t_lips-kunag.

MOVE vbrk-fkdat TO t_lips-fkdat.

MOVE vbrk-vbeln TO t_lips-vbelnbil.

  • Price is determined as follows according to VBRP entries.

MOVE vbrk-waerk TO t_lips-konwa. "Invoice Currency

WRITE : t_vbrp-netwr CURRENCY t_lips-konwa TO w_temp1.

w_cp = ','.

REPLACE ALL OCCURENCES OF w_cp IN w_temp1 WITH space.

t_lips-kbetr = w_temp1 / t_vbrp-fkimg.

t_lips-netwr = w_temp1.

ENDIF.

****************************************************************

IF p_bill EQ 'X'.

ELSE.

IF t_vbrp-fkimg NE '0'.

t_lips-kbetr = t_lips-netwr / t_vbrp-fkimg.

ELSE.

t_lips-kbetr = t_lips-netwr.

ENDIF.

t_lips-netwr = t_lips-netwr.

ENDIF.

ENDIF.

ENDIF.

  • In this part of change Batch Code is concatenated with the " " to down

  • load to Excel along with Leading Zeroes

CONCATENATE c_eqsign c_quotes t_lips-charg c_quotes INTO t_lips-charg.

MODIFY t_lips.

CLEAR t_lips.

CLEAR: konp, a005, w_vtweg, vbrk, t_vbrp.

ENDIF.

ENDLOOP.

  • reset fieldnames table

CLEAR t_fieldnames.

REFRESH t_fieldnames.

  • add column headings to field names table

MOVE 'Order Number'(014) TO t_fieldnames-name.

APPEND t_fieldnames.

CLEAR t_fieldnames.

MOVE 'Delivery Number'(010) TO t_fieldnames-name.

APPEND t_fieldnames.

CLEAR t_fieldnames.

MOVE 'Delivery Item Number'(011) TO t_fieldnames-name.

APPEND t_fieldnames.

CLEAR t_fieldnames.

MOVE 'Boots Material Code'(012) TO t_fieldnames-name.

APPEND t_fieldnames.

CLEAR t_fieldnames.

MOVE 'Customer Material Code'(013) TO t_fieldnames-name.

APPEND t_fieldnames.

CLEAR t_fieldnames.

MOVE 'Description'(015) TO t_fieldnames-name.

APPEND t_fieldnames.

CLEAR t_fieldnames.

MOVE 'Quantity'(016) TO t_fieldnames-name.

APPEND t_fieldnames.

CLEAR t_fieldnames.

MOVE 'Expected Delivery Date'(017) TO t_fieldnames-name.

APPEND t_fieldnames.

CLEAR t_fieldnames.

  • if batch details are to be extracted, add relevant column headings

IF p_both EQ 'X' OR p_batch EQ 'X'.

MOVE 'Batch'(030) TO t_fieldnames-name.

APPEND t_fieldnames.

CLEAR t_fieldnames.

MOVE 'Batch Expiry Date'(031) TO t_fieldnames-name.

APPEND t_fieldnames.

CLEAR t_fieldnames.

MOVE 'Manufacture Date'(066) TO t_fieldnames-name.

APPEND t_fieldnames.

CLEAR t_fieldnames.

ENDIF.

IF p_both = 'X' OR p_bill = 'X'.

MOVE 'Purch Order No'(036) TO t_fieldnames-name.

INSERT t_fieldnames INDEX 1.

CLEAR t_fieldnames.

MOVE 'Customer'(037) TO t_fieldnames-name.

INSERT t_fieldnames INDEX 2.

CLEAR t_fieldnames.

MOVE 'Invoice No'(038) TO t_fieldnames-name.

INSERT t_fieldnames INDEX 5.

CLEAR t_fieldnames.

MOVE 'Invoice Date'(039) TO t_fieldnames-name.

INSERT t_fieldnames INDEX 6.

CLEAR t_fieldnames.

MOVE 'Invoice Price Each'(040) TO t_fieldnames-name.

INSERT t_fieldnames INDEX 12.

CLEAR t_fieldnames.

MOVE 'Invoice Line Value'(041) TO t_fieldnames-name.

INSERT t_fieldnames INDEX 13.

CLEAR t_fieldnames.

MOVE 'Invoice Currency'(042) TO t_fieldnames-name.

INSERT t_fieldnames INDEX 14.

CLEAR t_fieldnames.

  • Heading for Details from MARA & MARC tables

MOVE 'Barcode Number'(054) TO t_fieldnames-name.

APPEND t_fieldnames.

CLEAR t_fieldnames.

MOVE 'Net Weight'(055) TO t_fieldnames-name.

APPEND t_fieldnames.

CLEAR t_fieldnames.

MOVE 'Gross Weight'(056) TO t_fieldnames-name.

APPEND t_fieldnames.

CLEAR t_fieldnames.

MOVE 'Material Freight Group'(057) TO t_fieldnames-name.

APPEND t_fieldnames.

CLEAR t_fieldnames.

MOVE 'Commodity Code'(058) TO t_fieldnames-name.

APPEND t_fieldnames.

CLEAR t_fieldnames.

MOVE 'Country of Origin'(059) TO t_fieldnames-name.

APPEND t_fieldnames.

CLEAR t_fieldnames.

MOVE 'Total Net Weight'(060) TO t_fieldnames-name.

APPEND t_fieldnames.

CLEAR t_fieldnames.

MOVE 'Total Gross Weight'(061) TO t_fieldnames-name.

APPEND t_fieldnames.

CLEAR t_fieldnames.

ENDIF.

IF p_both EQ 'X' OR p_batch EQ 'X'.

MOVE 'Basic Material'(062) TO t_fieldnames-name.

APPEND t_fieldnames.

CLEAR t_fieldnames.

ENDIF.

IF p_both EQ 'X'.

LOOP AT t_lips.

MOVE-CORRESPONDING t_lips TO t_lips_both.

APPEND t_lips_both.

CLEAR t_lips_both.

ENDLOOP.

PERFORM export_data TABLES t_lips_both t_fieldnames.

ELSEIF p_nether EQ 'X'.

LOOP AT t_lips.

MOVE-CORRESPONDING t_lips TO t_lips_no_batch_no_bill.

APPEND t_lips_no_batch_no_bill.

CLEAR t_lips_no_batch_no_bill.

ENDLOOP.

PERFORM export_data TABLES t_lips_no_batch_no_bill t_fieldnames.

ELSEIF p_bill EQ 'X'.

LOOP AT t_lips.

MOVE-CORRESPONDING t_lips TO t_lips_with_bill.

APPEND t_lips_with_bill.

CLEAR t_lips_with_bill.

ENDLOOP.

PERFORM export_data TABLES t_lips_with_bill t_fieldnames.

ELSEIF p_batch EQ 'X'.

LOOP AT t_lips.

MOVE-CORRESPONDING t_lips TO t_lips_with_batch.

APPEND t_lips_with_batch.

CLEAR t_lips_with_batch.

ENDLOOP.

PERFORM export_data TABLES t_lips_with_batch t_fieldnames.

ENDIF.

IF p_bill = 'X' OR p_both = 'X'.

PERFORM error_report USING c_space

'C'.

ENDIF.

ENDIF.

ENDIF.

ENDIF.

ENDFORM. " DOWNLOAD_DELIVERY

&----


*& Form EXPORT_DATA

&----


  • export data

----


  • -->P_T_LIPS text

  • -->P_T_FIELDNAMES text

----


FORM export_data TABLES p_t_lips

p_t_fieldnames STRUCTURE t_fieldnames.

DATA: l_vbeln LIKE rlgrap-filename,

w_userinput TYPE i.

DATA :filename TYPE string,

filefilter TYPE string,

new_file TYPE string.

  • update download table

CLEAR t_z194a.

REFRESH t_z194a.

t_z194a-vbeln = t_likp-vbeln.

t_z194a-dload_date = sy-datum.

t_z194a-dload_time = sy-uzeit.

t_z194a-uname = sy-uname.

APPEND t_z194a.

INSERT z194a FROM t_z194a.

  • download data to Excel

CALL FUNCTION 'GUI_FILE_SAVE_DIALOG'

EXPORTING

default_extension = '.xls'

file_filter = filefilter

IMPORTING

filename = filename

user_action = w_userinput.

IF filename IS INITIAL OR w_userinput NE 0.

EXIT.

ELSE.

new_file = filename.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

filename = new_file

write_field_separator = 'X'

  • CONFIRM_OVERWRITE = 'x'

  • REPLACEMENT = '#'

write_lf = 'X'

TABLES

data_tab = p_t_lips

fieldnames = p_t_fieldnames

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

OTHERS = 22.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

ENDIF.

REFRESH : p_t_lips, p_t_fieldnames.

CLEAR : p_t_lips, p_t_fieldnames.

ENDFORM. " EXPORT_DATA

&----


*& Form CONVERT_UNIT_MEASURE

&----


  • Convert the max storage period to days.

*

----


FORM convert_unit_measure USING p_lzeih TYPE marc-lzeih

p_maxlz TYPE marc-maxlz

CHANGING p_maxlz_days TYPE n

p_shelf_flag TYPE c.

*Note the unit of measurement is stored in German. eg. DAY = TAG

CASE p_lzeih.

WHEN '10' OR 'TAG'.

p_maxlz_days = p_maxlz. "Max storage period in days.

WHEN 'WCH'.

p_maxlz_days = p_maxlz * 7. "7 days in week.

WHEN 'MON'.

p_maxlz_days = p_maxlz * 30. "Assume 30 days in month.

WHEN 'JHR'.

p_maxlz_days = p_maxlz * 365. "Assume 365 days in a year.

WHEN 'H' OR 'STD' OR 'PS' OR 'MIN' OR 'MIS' OR 'MS' OR 'NS' OR 'S'.

p_shelf_flag = 'Y'.

WHEN OTHERS.

p_maxlz_days = p_maxlz.

ENDCASE.

ENDFORM. " CONVERT_UNIT_MEASURE

&----


*& Form ERROR_REPORT

&----


  • Form to create report of download

  • success.

----


  • -->P_T_LIPS-MATNR text *

  • -->P_error text *

----


FORM error_report USING p_space LIKE c_space

p_error TYPE c.

IF w_header IS INITIAL.

ULINE.

WRITE: /1 text-050,

21 sy-datum,

33 sy-uzeit,

50 text-051,

105 text-052,

113 sy-mandt,

123 text-053,

128 sy-pagno.

ULINE.

SKIP.

w_header = 'Y'.

ENDIF.

CASE p_error.

WHEN 'A'.

WRITE: /5 text-043,

52 p_space.

WHEN 'C'.

WRITE: /5 text-044.

CLEAR: w_header.

ENDCASE.

ENDFORM. " ERROR_REPORT

Message was edited by: ramesh

Message was edited by: ramesh

Former Member
0 Kudos

HI Prerna,

You can design your selection screen on the

similar logic given below.

constants: c_x TYPE c VALUE 'X',

c_path TYPE char100

VALUE '/local/data/interface/A28/DM/OUT'.

PARAMETERS : rb_pc RADIOBUTTON GROUP r1 DEFAULT 'X'

USER-COMMAND ucomm, "For Presentation

p_f1 LIKE rlgrap-filename

MODIF ID rb1, "Input File

rb_srv RADIOBUTTON GROUP

r1, "For Application

p_f2 LIKE rlgrap-filename

MODIF ID rb2, "Input File

p_direct TYPE char128 MODIF ID abc DEFAULT

c_path.

AT SELECTION-SCREEN OUTPUT.

LOOP AT SCREEN.

IF rb_pc = c_x AND screen-group1 = 'RB2'.

screen-input = '0'.

MODIFY SCREEN.

ELSEIF rb_srv = c_x AND screen-group1 = 'RB1'.

screen-input = '0'.

MODIFY SCREEN.

ENDIF.

IF screen-group1 = 'ABC'.

screen-input = '0'.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

Reward points if this helps.

Manish

Former Member
0 Kudos

Hi,

U may try following code:

AT SELECTION-SCREEN.

PERFORM validate_input.

....

....

FORM validate_input .

If P-swa <> ' ' .

If s_date(ie Posting Date) is initial.

messagee e000(message id ) with 'Please Enter Posting Date'.

endif.

endif.

If P-pre = ' ' .

If s_bukrs is initial.

messagee e000(z1) with 'Please Enter Company Code'.

endif.

endif.

Note: pl ck in u r system wat message id n class u r using . Use that one.

Cheers..

Sunanda