Application Development and Automation 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: 
Read only

Need Logic to implement

Former Member
0 Likes
1,104

Hi Experts ,

I have below piece of code , if  zz_orgsys and zz_roeid field (custom fields in standard table) has value then it will perform below logic and print the Label xyz along with value in final invoice . But if these ZZ fields dont have any values then neither label nor any value will be printed in invoice  . How can I apply the logic .

*** Logic to get roid

  CLEAR : lv_orgsys, lv_roeid.

SELECT SINGLE zz_orgsys zz_roeid FROM vbak INTO (lv_orgsys , lv_roeid)

                            WHERE vbeln EQ w_ordno.

**Begin of Logic

  IF sp_adrc-country    EQ c_in AND

     ( lv_roeid+0(2)    EQ c_ep OR lv_roeid+0(2)   EQ c_eb )

     AND lv_orgsys      EQ c_epr.

    PERFORM toget_lstcst_yinc.

  ELSE.

    CLEAR ws_kunnr.

    CLEAR w_lstcst.

    SELECT SINGLE kunnr FROM vbpa INTO ws_kunnr

                         WHERE vbeln = w_ordno

                         AND   parvw = 'WE'.

    PERFORM toget_lstcst.

  ENDIF.

***End of logic

  w_shipcst = w_lstcst.

  CLEAR w_lstcst.

Thanks

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,074

Hi MM,

This is logic

  CLEAR : lv_orgsys, lv_roeid.

SELECT SINGLE zz_orgsys zz_roeid FROM vbak INTO (lv_orgsys , lv_roeid)

                            WHERE vbeln EQ w_ordno.

**Begin of Logic

**Check if you got values in lv_orgsys and lv_roeid, if you got values then preform your logic else nothing.

IF lv_orgsys IS NOT INITIAL AND lv_roeid IS NOT INITIAL.

  IF sp_adrc-country    EQ c_in AND

     ( lv_roeid+0(2)    EQ c_ep OR lv_roeid+0(2)   EQ c_eb )

     AND lv_orgsys      EQ c_epr.

    PERFORM toget_lstcst_yinc.

  ELSE.

    CLEAR ws_kunnr.

    CLEAR w_lstcst.

    SELECT SINGLE kunnr FROM vbpa INTO ws_kunnr

                         WHERE vbeln = w_ordno

                         AND   parvw = 'WE'.

    PERFORM toget_lstcst.

  ENDIF.

***End of logic

ENDIF.

  w_shipcst = w_lstcst.

  CLEAR w_lstcst.

9 REPLIES 9
Read only

Former Member
0 Likes
1,074

Hi,

i am not sure if it works but you can try something like this:

SELECT SINGLE zz_orgsys zz_roeid FROM vbak INTO (lv_orgsys , lv_roeid)

                            WHERE vbeln EQ w_ordno

                            AND zz_orgsys IS NOT NULL

                            AND zz_roeid IS NOT NULL.

IF sy-subrc = 0.

  IF sp_adrc-country    EQ c_in AND

     ( lv_roeid+0(2)    EQ c_ep OR lv_roeid+0(2)   EQ c_eb )

     AND lv_orgsys      EQ c_epr.

    PERFORM toget_lstcst_yinc.

  ELSE.

    CLEAR ws_kunnr.

    CLEAR w_lstcst.

    SELECT SINGLE kunnr FROM vbpa INTO ws_kunnr

                         WHERE vbeln = w_ordno

                         AND   parvw = 'WE'.

    PERFORM toget_lstcst.

  ENDIF.

ENDIF.

***End of logic

  w_shipcst = w_lstcst.

  CLEAR w_lstcst.

Read only

0 Likes
1,074

An other way:

SELECT SINGLE zz_orgsys zz_roeid FROM vbak INTO (lv_orgsys , lv_roeid)

                            WHERE vbeln EQ w_ordno.



     if zz_orgsys is not INITIAL.
          ...         

     ENDIF.  

Regards

Jürgen


Read only

Former Member
0 Likes
1,074

Hi MM,

try this logic,hope this will work.

SELECT SINGLE zz_orgsys zz_roeid FROM vbak INTO (lv_orgsys , lv_roeid)

                            WHERE vbeln EQ w_ordno

                            AND zz_orgsys <> ''

                            AND zz_roeid <> ' '.

IF sy-subrc = 0.

clear:lv_roeid_temp.

lv_roeid_temp = lv_roeid+0(2). 

  IF sp_adrc-country    EQ c_in AND

     ( lv_roeid_temp   EQ c_ep OR lv_roeid_temp   EQ c_eb )

     AND lv_orgsys      EQ c_epr.

    PERFORM toget_lstcst_yinc.

  ELSE.

    CLEAR ws_kunnr.

    CLEAR w_lstcst.

    SELECT SINGLE kunnr FROM vbpa INTO ws_kunnr

                         WHERE vbeln = w_ordno

                         AND   parvw = 'WE'.

    PERFORM toget_lstcst.

  ENDIF.

ENDIF.

***End of logic

  w_shipcst = w_lstcst.

  CLEAR w_lstcst.

Read only

0 Likes
1,074

Hi Sangamesh ,

Thanks .Will surely give a try . I am a functional so dont have a developer access key . Need to pass it on to a ABAP er . But with the above logic when there is no i/p the label wont be printed right ?

Because I dont want to print the label with blank value .

Read only

Former Member
0 Likes
1,074

I hope you are using smartform for showing the final invoice print .

If so, add a condition for the label as well as the text element used for displaying these fileds such as :

if the variable to be printed is z_orgsys.

add condition

z_orgsys NE initial. for both the label as well as the value field.

(NE will be symbol in smart form in condition tab)

Read only

0 Likes
1,074

Hi Devanand ,

I am using SAP Script.

Read only

bharat_rathod2
Active Participant
0 Likes
1,074

Dear,

can u send me full code and SF for more clarification of your problem.

Read only

Former Member
0 Likes
1,074

Hi MM,

If u r using zz_orgsys and zz_roeid fields as ur value fields to print value and label field name say 'xyz' using,Then make sure that these fields are character fields.If there is no value,Then nothing will be printed invoice.

If they are not character fields,Then pass those values to character fields and put condition like.

If zz_orgsys is initial.

clear zz_orgsys.

endif.

If zz_roeid is initial.

clear zz_roeid.

endif.

Hope this will help you.

Read only

Former Member
0 Likes
1,075

Hi MM,

This is logic

  CLEAR : lv_orgsys, lv_roeid.

SELECT SINGLE zz_orgsys zz_roeid FROM vbak INTO (lv_orgsys , lv_roeid)

                            WHERE vbeln EQ w_ordno.

**Begin of Logic

**Check if you got values in lv_orgsys and lv_roeid, if you got values then preform your logic else nothing.

IF lv_orgsys IS NOT INITIAL AND lv_roeid IS NOT INITIAL.

  IF sp_adrc-country    EQ c_in AND

     ( lv_roeid+0(2)    EQ c_ep OR lv_roeid+0(2)   EQ c_eb )

     AND lv_orgsys      EQ c_epr.

    PERFORM toget_lstcst_yinc.

  ELSE.

    CLEAR ws_kunnr.

    CLEAR w_lstcst.

    SELECT SINGLE kunnr FROM vbpa INTO ws_kunnr

                         WHERE vbeln = w_ordno

                         AND   parvw = 'WE'.

    PERFORM toget_lstcst.

  ENDIF.

***End of logic

ENDIF.

  w_shipcst = w_lstcst.

  CLEAR w_lstcst.